jquery class selector – How to use jQuery Class and Id Selector to find DOM elements?

jquery class selector. The .class selector specifies the class for an element to be selected. The jQuery class selector finds elements with a specific class.

jquery class selector

The element class selector selects all the elements which match with the given class of the elements. we will learn jQuery class Selector with examples.

jQuery – Element Class Selector

index.html

<html>
   <head>
      <title>The Selecter Example - www.pakainfo.com</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() {
            /* This would select second division only*/
            $(".large").css("background-color", "yellow");
         });
      </script>
   </head>
	
   <body>
      <div class = "large" id="computer">
         <p>jquery get element by class.</p>
      </div>

      <div class = "medium" id = "laptop">
         <p>jquery multiple class selector.</p>
      </div>

      <div class = "small" id = "mobile">
         <p>jquery class selector loop</p>
      </div>
   </body>
</html>

jQuery select by class

index.html

<html>
<head>
<title>jQuery select by Class</title>

<style>
div, span {
width: 130px;
height: 50px;
float: left;
padding: 15px;
margin: 15px;
background-color: #EEEEEE;
}
</style>

<script src="//code.jquery.com/jquery-3.2.1.js"></script>

</head>
<body>
<div class="mobile">div element className="mobile"</div>
<div class="laptop">div element className="laptop"</div>
<span class="computer">span element className="computer"</span>
<script>
$( ".laptop" ).css( "border", "5px solid green" );
</script>
</body>
</html>

The Name Selector

$("input[name='newCar']").action();

Example
$(document).ready(function(){
  $("button").click(function(){
    $("input[name='newCar']").hide();
  });
});

jQuery multiple selectors

Also Read This πŸ‘‰   Dynamically Add delete rows with JQuery Multiple datepicker

I hope you get an idea about jquery class selector.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.