How to create an empty, non-null jQuery object ready for appending?

后端 未结 6 2006
傲寒
傲寒 2021-02-06 21:04

I want to append some html to an empty non null jQuery object only in the loop but it\'s not working unless I create an object and add an html tag during creation. How can I cre

6条回答
  •  一个人的身影
    2021-02-06 21:11

    I couldn't find another way so I started with the . Removing the while keeping the contents didn't work properly and that's why I posted the question. So, instead, I created a new jQuery selection by selecting all the 's which were inside the and threw away $new.

    var $new = $().add("");  
    
    $.each(.....)
      {
        $new.append("");
    
    });
    $new.append("");
    $newObject = $('sometagt', $new)
    ..... do more work using $newObject
    

提交回复
热议问题