Example of Descendant Selector in jQuery
May 01, 2013
Descendant Selector means, the nested element can be selected and we can use for own cause. As an example inside a div, then inside span if we have an element text, we can select that and use that one. Sample example is given below.
<html> <head> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> </head> <body> <div> <span> <input type=text value="yellow"/> </span> <input type=text value="blue"/> </div> <input type=text/> <script> $( "div input" ).css( "backgroundColor", "blue" ); $( "div span input" ).css( "backgroundColor", "yellow" ); </script> </body> </html>
Output