jQuery Tutorial plus Question:
Download Job Interview Questions and Answers PDF
Define each() function in jQuery?
Answer:
The each() function specify the function to be called for every matched element.
Syntax:
$(selector).each(function (index, element))
"index" is the index position of the selector.
"selector" specifies the current selector where we can use "this" selector also.
In the case when we need to stop the each loop early then we can use "return false;"
For example:
$("#clickme").click(function(){
$("li").each(function(){
document.write($(this).text())
});
});
This will write the text for each "li" element.
Syntax:
$(selector).each(function (index, element))
"index" is the index position of the selector.
"selector" specifies the current selector where we can use "this" selector also.
In the case when we need to stop the each loop early then we can use "return false;"
For example:
$("#clickme").click(function(){
$("li").each(function(){
document.write($(this).text())
});
});
This will write the text for each "li" element.
Download jQuery Interview Questions And Answers
PDF
Previous Question | Next Question |
Derfine width() vs css('width')? | Define slideToggle() effect? |