For a long time without using jquery, when doing the project encountered a small problem is that the page load after the Append element is able to execute the Click event, after the Web page loading is complete, again append element does not perform the Click event, simply through the UL simulation:
<ul class= "Content" > </ul> <span class= "test" > Test </span>
Three different click Modes, the click after append is not valid, by on execution, note the parameters:
$ (function () { $ ('. Content '). Append (' <li>FlyElephant</li> '); $ ('. Content li '). Click (Function (event) { console.log (' Blog Park-flyelephant '); }); $ ('. Content li '). On (' click ', Function () { console.log (' Blog Park-flyelephant '); }); /* General */ $ (document). On (' click ', '. Content li ', function () { console.log (' Keso '); }); $ ('. Test '). Click (function () { $ ('. Content '). Append (' <li>keso</li> '); });
jquery version 2.1.4~
Jquery-append add Element Click Invalid