Multiple expressions (E, F, G)
In this chapter you will learn:
Description and Syntax
$('E, F, G')
selects all elements matched by any
of the selector expressions E
, F
,
or G
.
Examples
$('code, em, strong')
selects all<code>
,<em>
, and<strong>
elements.$('p strong, .myclass')
selects all<strong>
elements that are descendants of a<p>
element, as well as all elements that have a class ofmyclass
<html><!-- ja v a 2 s . co m-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div,span,p.myClass").css("color","red");
});
</script>
</head>
<body>
<body>
<div>div</div>
<p class="myClass">p class="myClass"</p>
<p class="notMyClass">p class="notMyClass"</p>
<span>span</span>
</body>
</html>
Next chapter...
What you will learn in the next chapter:
- Description and Syntax for Universal selector
- Examples for Universal selector
- How to select all elements under a certain element
- How to select all elements