Jquery contains() Filter
- Jquery contains() selectors get a content of a selected element which specified in the parameter.
- This selector helps to extract content from an element.
$(document).ready(function () { $('button').click(function () { $('p:contains(select)').text()); }); });
- Jquery :contains() selector select which paragraph contains a selected text.
- This selection not depending on word spacing.
: Empty Filter
- Jquery: empty selector select which element didn't have textual content or it to be empty.
$(document).ready(function () { $('button').click(function () { $('p:empty').text("hai")); }); });
- This example gets the paragraph that has empty and set a parameter value to an element.
:has() Filter
- Jquery has() selector returns a boolean values only.
- Which element have a matched content then only it returns true otherwise it returns false.
$(document).ready(function () { $('button').click(function () { $('p:has(span)').css("background","red")); }); });
- In this example show which p has a span that background only changes the mentioned color.
: parent Filter
- A parent selector used to reach out to the child elements.
- The referred parent get all it's child elements.
$(document).ready(function () { $('button').click(function () { $("td:parent").css("background-color", "orange"); }); });
- In this example get the parent of td and push it into the jquery manipulation.
: visibility Filter
- Jquery: visibility filters receive only a visible element. It refuses the hidden elements.
$(document).ready(function () { $('button').click(function () { $("p:visible").text() ; }); });
- It notices the visible elements
: Hidden Filter
- Invisible elements are to be select.
$(document).ready(function () { $('button').click(function () { $("p:hidden").show() ; }); });
- The hidden elements are only shown.
Post A Comment:
0 comments: