Select the paragraph with only specific class - Javascript jQuery Selector

Javascript examples for jQuery Selector:class

Description

Select the paragraph with only specific class

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from w ww  .  j  a  v a  2s .  c  om*/
$('p[class="p"]').css('color', 'red');
    });

      </script> 
   </head> 
   <body> 
      <p class="p">Paragraph</p> 
      <p class="p p2">Paragraph 2</p> 
      <p class="p p3">Paragraph 3</p>  
   </body>
</html>

Related Tutorials