Created
August 6, 2013 09:55
-
-
Save willhalling/6163259 to your computer and use it in GitHub Desktop.
.children() method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> | |
<title>.children() method</title> | |
<script type="text/javascript"> | |
$(function() { | |
// children() only travels a single level down the DOM tree while .find() can traverse down multiple levels | |
$('li').children().css('background','red'); | |
}); | |
</script> | |
</head> | |
<body> | |
<ul id="parent"> | |
<li>Parent 1</li> | |
<li>Parent 2 | |
<ul id="children"> | |
<li>Child 1</li> | |
<li>Child 2</li> | |
<li>Child 3</li> | |
</ul> | |
</li> | |
<li>Parent 3</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment