Select the button after adding by using html() - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Select the button after adding by using html()

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.11.3.min.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//from  w w  w. jav a2  s . com
$(document).ready(function(){
  $('#test').html('<input type="button" id="save_1" value="a1" />');
    $(document).on('click', 'input[id^=save_]', function(){
    console.log('hi');
    });
});
    }

      </script> 
 </head> 
 <body> 
  <div id="test"> 
  </div>  
 </body>
</html>

Related Tutorials