Saturday, August 24, 2013

FIND() selector in Jquery


To make partial views to preserve the values while doing the http post we need to pass the top level model(parent view model) to partial view.
find() lets you filter on a set of elements based on a selection you've already made. For example if you wanted to set the back-ground color to all the spans inside a div, you could write:

$('#testDiv').find('span').css('background-color', 'red');

We can do the same by using below syntax
$('#testDiv span').css('background-color', 'red');


Here “testDiv” is a div tag.


Find selector is a much faster comparative to above one.

No comments:

Post a Comment