Detect if any span contains exactly one specific class - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:css

Description

Detect if any span contains exactly one specific class

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
      <title>Attribute Equal Selector with Class</title> 
   </head> 
   <body> 
      <span class="system-on blue">1</span> 
      <span class="system-on">2</span> 
      <span class="system-on blue">3</span> 
      <script>
    $("span[class=system-on]").css("color", "red");
  
      </script>  
   </body>/*from ww w .  j a  v a  2  s. c om*/
</html>

Related Tutorials