jquery - how to apply to avoid adding all .test classes from the page in the code $( ".test" ).insertBefore( ".test1" ) -
how apply avoid adding .test classes page in code
$( ".test" ).insertbefore( ".test1" )
<div id="testdiv"> <div class="test1"></div> <div class="test"></div> </div>
div replicated on page
you need iterate on each test element , insert before previous sibling .test
:
$(".test").each(function(){ $(this).insertbefore($(this).prev()); }) ;
Comments
Post a Comment