Bind a click to a dynamic button with jQuery?

后端 未结 3 2080
旧时难觅i
旧时难觅i 2021-01-24 17:32

I want to create a button that has a jQuery click on the fly. After the user is done and hit the button I want to destroy the button and the jQuery click until a time I need it

3条回答
  •  抹茶落季
    2021-01-24 18:07

    This should work. Change html in strings appropriately:

       $('#targetdiv').append( $("
    foobar
    ").click( function(evt) { $(this).remove(); }))

    Here's a demo site showing it in action.

提交回复
热议问题