Change class of a span inside a button on click - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Change class of a span inside a button on click

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
      <script>
$(document).ready(function(){
$("#btn_new").click(function(){
   $(this).find('span').toggleClass('main');
});//from w  ww.  j  a  v a  2  s  .co m
});

      </script> 
      <style>

.main {
   font-size: 120%;
   color: red;
}

      </style> 
   </head> 
   <body> 
      <button type="button" id="btn_new"> 
         <span class="main">new</span> 
      </button>  
   </body>
</html>

Related Tutorials