Define each() function in jQuery?
Submitted by: AdministratorThe 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.
Submitted by:
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.
Submitted by:
Read Online jQuery Job Interview Questions And Answers
Top jQuery Questions
☺ | Different ways of using $.connect function in jQuery? |
☺ | Explain how jQuery Works? |
☺ | Why is jQuery better than JavaScript? |
☺ | Advantages of jQuery. |
☺ | When can you use jQuery? |
Top Top World Wide Web Categories
☺ | Cascading Style Sheet CSS Interview Questions. |
☺ | HTML5 Interview Questions. |
☺ | Basic Internet Interview Questions. |
☺ | Domain Name System (DNS) Interview Questions. |
☺ | JavaScript Interview Questions. |