Event binding by listening for matching child elements under a parent container
<div id= "Test1" > <input type= "button" class= "BTN" value= "button 1"/> <input type= "button" class= "BTN" Valu e= "button 1"/> <input type= "button" class= "BTN" value= "button 1"/> <p></p></div><input type= "but Ton "class=" Add "value=" plus a button "/><script type=" Text/javascript "src=" Js/jquery-1.10.2.min.js "></script ><script type= "Application/javascript" >$ (function () {$ (' #test1 '). On (' click ', '. Btn ', function () {alert (' Bind valid 1 ')}), $ ('. Add '). On (' click ', Function () {$ (' #test1 '). Append (' <input type= "button" class= "BTN" value= "button 2"/ > ')}); </script>
$ ('. Add '). On (' click ', Function () {$ (' #test1 '). Append (' <input type= "button" class= "BTN" value= "button 2"/> "); $ ('. Btn '). On (' click ', Function () {});});
The solution of invalid JS for dynamic new element