Onblur event added to new created element - Javascript jQuery

Javascript examples for jQuery:Form Event

Description

Onblur event added to new created element

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-2.0.2.js"></script> 
 </head> /*  www .jav  a 2 s  . com*/
 <body> 
  <div onclick="wrap($(this))">
    999999999 
  </div> 
  <script type="text/javascript">
function wrap(sel) {
    sel.html('<input onblur="unwrap($(this));" value="' + sel.html() + '" />');
    sel.attr('onclick', '');
    $("input").focus();
}
function unwrap(child) {
    console.log('Unwrapping');
}

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

Related Tutorials