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
for (var i = 0; i
lis[i].onclick = function () {
alert(id);
};
} // All li's get and alert the last li's id
There is
Comments
Post a Comment