Change an individual element based on a class jquery callback function - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:css

Description

Change an individual element based on a class jquery callback function

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>

.myClass {// w  w w . jav a  2 s . c  o  m
   width: 300px;
   height: 300px;
   background: #f00;
}


      </style> 
 </head> 
 <body translate="no"> 
  <div class="myClass"></div> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
  <script>
      $('.myClass').click( function(){
         $(this).css('width', '30%');
         console.log("test");
});

    
      </script>  
 </body>
</html>

Related Tutorials