How can I refresh a stored and snapshotted jquery selector variable

后端 未结 6 1586
温柔的废话
温柔的废话 2020-12-13 13:46

I ran yesterday in a problem with a jquery-selector I assigned to a variable and it\'s driving me mad.

Here is a jsfiddle with testcase:

  • assign the .el
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 14:00

    If you use remove() it will remove only a part of the DOM but not all the children or related, instead if you use empty() on the element the problem is gone.

    E.G.:

     $('#parent .child).find('#foo').empty();
    

    Maybe it can be useful to someone!

提交回复
热议问题