I am playing with JavaScript and have set myself the task of converting some jQuery I wrote last night to pure JavaScript. I've come across a few questions I was wondering if someone cold help me with.
- is
$(this)a jQuery object, and not used in pure JavaScript (isthis.somethingthe same)? - can you easily do something like
.after()in pure JavaScript or is it just silly?
I'm converting this in to pure JavaScript at the moment..
$('.list li').each(function(i) {
if( ( i + 1 ) % numRow == 0 )
{
$(this).after( "<div class='rowBreak'></div>" );
}
});
so far I have this:
var totalThumbs = $('.list li').length;
for ( var i = 0; i < totalThumbs; i++ ) {
if( ( i + 1 ) % numRow == 0 )
{
$(this).after( "<div class='rowBreak'></div>" );
}
}
totalThumbscoming from? Is there an array or collection of some sort associated with it?$is the jquery object. In pure javascript there is no$(unless you define it).$()is jQuery.thisgets context ineachbut you don't have that context inforloopthisis available though, but it has to reference something :) As you've written it there is nothisavailable (not in normal js or jquery)