How to destroy a DOM element with jQuery?

前端 未结 4 1952
攒了一身酷
攒了一身酷 2020-12-01 08:51

Suppose the jQuery object is $target.

4条回答
  •  盖世英雄少女心
    2020-12-01 09:34

    Not sure if it's just me, but using .remove() doesn't seem to work if you are selecting by an id.

    Ex: $("#my-element").remove();

    I had to use the element's class instead, or nothing happened.

    Ex: $(".my-element").remove();

提交回复
热议问题