Class Selector jQuery Example


$(“.class”) – selector is used to select the elements in the page which have class “.class”.


Class Selector jQuery Example – $(“.class”)

Class Selector jQuery Example with syntax

<!DOCTYPE html>
<html>
<head>
<title>jQuery $(".class") Example</title>
 <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js">
 </script>
<script type="text/javascript">
         $(document).ready(function(){        
          $("div.myclass").css("border","4px solid red");
          $("p.myclass").css("background","yellow");
          $("span.myclass").css("font-size","36px");
          });
         
</script> 
  
</head>	
<body>
   <div class="myclass"> 
      Div One..
   </div>
   <br>
   <div> 
    Div Two..
    </div>
    <p class="myclass"> 
      Paragraph..
    </p>
    <span class="myclass"> 
     Span...
    </span>

</body>
</html>             

Try it »


User Ans/Comments

📖 Read More


Advertisements