jQuery Examples - $("a#specialID.specialClass")



Description

"$("a#specialID.specialClass")" selects all the anchors which have an id specialId and having class as specialClass.

Syntax

Here is the simple syntax to use this selector −

$("tagname#specialID.specialClass")

Parameters

Here is the description of all the parameters used by this selector −

  • tagnamee − Any standard HTML tag name like div, p, em, img, li etc.

  • .specialID − id of the element.

  • .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

Live Demo
<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.*/
            $("a#first.big").css("background-color", "yellow");
         });
      </script>
   </head>
	
   <body>
      <ul>
         <li><a id = "first" class="big" href="#">Big</a></li>
         <li><a id = "first" class="medium" href="#">Medium</a></li>
         <li><a id = "first" class="small" href="#">Small</a></li>
      </ul>
   </body>
</html>

This will produce following result −

jqueryexamples_selectors.htm
Advertisements