I created a counter that count different numbers each, but when I choose all the elemnts in class it doesnt work…
$(document).ready(function() {
function change() {
/*
$(".test").each(function(i,domeElement){
var theNum = parseInt(this.html())+1;
this.html(theNum);
});
*/
//this works... the other one doesnt why?!?!
var theNum = parseInt($(".test").html()) + 1;
$(".test").html(theNum);
}
setInterval(change, 1000);
});
You should use
and not
Because
html()is a jQuery function andthis(inside.each()) is a domElement and so you must wrap it into a jQuery objectFiddle here: http://jsfiddle.net/nicolapeluchetti/DTyY7/2/