Appending HTML w/click event using jQuery

前端 未结 4 2181
小蘑菇
小蘑菇 2021-02-20 15:59

I want to append some HTML inside this div, and the HTML has to have a click event on it also.

    

hello, world!

4条回答
  •  北海茫月
    2021-02-20 16:34

    As of jQuery 1.3, this will work:

    hello, world!

    $(".myClass").live("click", function(){ $(this).after("

    Another paragraph!

    "); });

    See more about live events on this page:

    http://docs.jquery.com/Events

提交回复
热议问题