Only the last element is bound/inserted/etc. in your javascript code’s “for” loop

There is a common problem when you use javascript for loop to bind an event function or add a class that comes from looping selection’s attributes. To make clear what I mean consider this example: var lis = $('ul li');

for (var i = 0; i var id = lis[i].id;
lis[i].onclick = function () {
alert(id);
};
} // All li's get and alert the last li's id

There is

Comments

Popular posts from this blog

Genuine Windows 7 Ultimate: The GENUINE Windows 7 activator for x32 and x6480

Types and forms of imitation gemstone and manufactured

7 Tips before you buy detectors for gold and treasures and minerals