Getting the contents of an element WITHOUT its children

前端 未结 5 1457
醉话见心
醉话见心 2020-12-10 11:18

I have a mild preference in solving this in pure JS, but if the jQuery version is simpler, then jQuery is fine too. Effectively the situation is like this

&l         


        
5条回答
  •  天命终不由人
    2020-12-10 12:13

    Have you tried something like this?

    var thisone = $("#thisone").clone();
    thisone.children().remove();
    var mytext = thisone.html();
    

提交回复
热议问题