Tuesday, 15 May 2012

jQuery DOM Traversal

.filter()
Reduce the set of matched elements to those that match the selector or pass the function's test.
Ex:
<div></div>
<div class="middle"></div>
<div class="middle"></div>
<div class="middle"></div>
<div class="middle"></div>
<div></div>


$("div").filter(".middle“).css("border-color", "red");


. siblings()
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
Ex:
<div>
                <span class=“oldStyle”></span>
                <a></a>
                <ul class=“oldStyle”></ul>
</div>


$("div”). siblings(“.oldStyle“).css("border-color", "red");



No comments:

Post a Comment