javascript - array with doms turns into variable if only a single exists -
javascript - array with doms turns into variable if only a single exists -
so pretty basic jquery guess.
var counters = $(".move-counter"); (var key in counters) { console.log(counters[key].text()); } the problem here is, if element class move-counter variable counters wont array, single element, making other .text() fail. can create sure turns array (in way other doing simple .length or of like)?
use jquery's .each() method iterate on elements in collection.
$(".move-counter").each(function() { console.log($(this).text()); }); javascript jquery
Comments
Post a Comment