jQuery Examples - $("p a.specialClass")
Description
"$("p a.specialClass")" selects all the anchors which have class as specialClass and are declared with <p> element.
Syntax
Here is the simple syntax to use this selector −
$("tagname child-element.specialClass")
Parameters
Here is the description of all the parameters used by this selector −
tagname − Any standard HTML tag name like div, p, em, img, li etc.
child-element − Any standard HTML tag name like a, p, em, img, li etc.
.specialClass − style class applied on the element.
Returns
Like any other jQuery selector, this selector also returns an array filled with the found elements.
Example
<html>
<head>
<title>The Selector Example</title>
<script type = "text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
/* Select link with an id of first and a class of big.*/
$("p a.medium").css("background-color", "yellow");
});
</script>
</head>
<body>
<p><a id = "first" class="big" href="#">Big</a></p>
<p><a id = "second" class="medium" href="#">Medium</a></p>
<p><a id = "last" class="small" href="#">Small</a></p>
</ul>
</body>
</html>
This will produce following result −
jqueryexamples_selectors.htm
Advertisements