![](/img/trans.png)
[英]How do I look for a tag's ID using the known html content inside the tag using javascript or jQuery?
[英]How to move an HTML tag after an id with JavaScript without using jQuery?
<div id="A"></div>
<div id="B"></div>
<div id="D"></div>
<div id="E"></div>
<div id="C"></div>`
如何使用纯JavaScript(没有JQuery)在ID B和D之间移动<div id="C"></div>
?
您可以使用insertBefore :
var C = document.getElementById("C");
var D = document.getElementById("D");
D.parentElement.insertBefore(C, D);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.