From jQuery JavaScript Library
« Back to Selectors
ancestor descendant
Matches all descendant elements specified by "descendant" of elements specified by "ancestor".
Arguments:| ancestor | Selector | |
|---|
| Any valid selector. |
| descendant | Selector | |
|---|
| A selector to match elements that are descendants of the first selector. |
Examples:| Name | Type |
Finds all input descendants of forms.
$("form input").css("border", "2px dotted blue");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("form input").css("border", "2px dotted blue");
});
</script>
<style>
body { font-size:14px; }
form { border:2px green solid; padding:2px; margin:0;
background:#efe; }
div { color:red; }
fieldset { margin:1px; padding:3px; }
</style>
</head>
<body>
<form>
<div>Form is surrounded by the green outline</div>
<label>Child:</label>
<input name="name" />
<fieldset>
<label>Grandchild:</label>
<input name="newsletter" />
</fieldset>
</form>
Sibling to form: <input name="none" />
</body>
</html>