javascript - Move HTML element before other in prototype -


i wokring in magento enviroment js create dynamic html.now want move 1 element before other.as possible because html loading form js , replace applied on ? final html code displayed :

<div class="x-tree-node-el folder active-category x-tree-node-collapsed" id="extdd-3"><span class="x-tree-node-indent"><img class="x-tree-icon" src="http://extjs.com/s.gif"></span><img class="x-tree-ec-icon x-tree-elbow-plus" src="http://extjs.com/s.gif" id="ext-gen27"><img unselectable="on" class="x-tree-node-icon" src="http://extjs.com/s.gif" id="ext-gen24"><a tabindex="1" href="#" hidefocus="on" id="ext-gen21"><span unselectable="on" id="extdd-4">laptops (2)</span></a><input type="checkbox" class="copycate" value="110" name="tree['110']"></div> 

i want move input typ="checkobx" before anchor tage.like final result

 <div class="x-tree-node-el folder active-category x-tree-node-collapsed" id="extdd-3"><span class="x-tree-node-indent"><img class="x-tree-icon" src="http://extjs.com/s.gif"></span><img class="x-tree-ec-icon x-tree-elbow-plus" src="http://extjs.com/s.gif" id="ext-gen27"><img unselectable="on" class="x-tree-node-icon" src="http://extjs.com/s.gif" id="ext-gen24"> <input type="checkbox" class="copycate" value="110" name="tree['110']"> <a tabindex="1" href="#" hidefocus="on" id="ext-gen21"><span unselectable="on" id="extdd-4">laptops (2)</span></a></div> 

i try code don't work.

 <script>   $('.copycate').insert({   before: "<a>",   after: "<img>" });   </script> 

$('.copycate').insertbefore($('#ext-gen21')); 

jquery api - insertbefore


Comments