Thursday, 8 August 2013

jQuery iterate on all elements

jQuery iterate on all elements

I have a with id "#list" and on click of some button I want to increase
the size of all list elements by 50px.
Why does the following code doesn't work:
function Test(){
$("#list li").each(function(){
var h = this.height() + 50;
this.height(h);
});
}
This function is activated on button click and I get the next error:

Uncaught TypeError: Object #<HTMLLIElement> has no method 'height'
index.html:32
(anonymous function) index.html:32
b.extend.each jquery-1.9.1.min.js:152
b.fn.b.each jquery-1.9.1.min.js:45
Test index.html:31
onclick index.html:44

No comments:

Post a Comment