Appending a “delete link” to cloned elements with JQuery

前端 未结 1 1791
情歌与酒
情歌与酒 2021-01-26 11:45

All,

I need to add a \"delete\" link to the end of all of my cloned sections, but not the source of the cloned material. This is what I have so far

Need somethin

相关标签:
1条回答
  • 2021-01-26 12:34

    Try this:

     var deleteLink = $("<a>delete</a>");
     deleteLink.appendTo(copy);
     deleteLink.click(function(){
         copy.remove();
     });
    

    Note that you'll need to style the delete link appropriately since it doesn't have an href.

    JSFiddle: http://jsfiddle.net/5QBLB/

    0 讨论(0)
提交回复
热议问题