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
Post a Comment