Update DOM using jQuery without chaining current object -


i find myself selecting element, going down dom update html/text/etc, , going dom element.

without doing either of following, there clean way of doing so?

$('#foo').clone(true).children('a.bar').text('bla').parent().appendto(blabla);  var myelem=$('#foo').clone(true); myelem.children('a.bar').text('bla'); myelem.appendto(blabla); 

you seem looking jquery's .end(). allows pop last added set of elements off stack.

$("p")    .find("span")    .end()    .css("border", "2px red solid");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <p><span>hello</span>, how you?</p>


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -