Dieser Artikel beschreibt die Definition und Verwendung von JavaScript InsertAfter (). Teilen Sie es für Ihre Referenz wie folgt weiter:
HTML -Teil:
<div id = "b"> BBBBBBBB </div> <div> dddddd </div>
JavaScript -Teil:
window.onload = function () {var a = document.createelement ("span"); var b = document.createTextNode ("cssrain"); A.Appendchild (b); var mubiao = document.getElementById ("b"); InsertAfter (a, mubiao); } function InsertAfter (newElement, targetElement) {var parent = targetElement.parentnode; if (parent.lastchild == targetElement) {// Wenn der letzte Knoten das Zielelement ist, fügen Sie es direkt hinzu. Weil der Standard der letzte übergeordnete. AppendChild (NewLeement) ist; } else {parent.insertBefore (newElement, targetElement. Das heißt, hinter dem Zielelement. }}For more information about JavaScript related content, please check out the special topics of this site: "Summary of Common JavaScript Function Skills", "Summary of JavaScript Switching Special Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Fähigkeiten "," Zusammenfassung des JavaScript -Traversalalgorithmus und der Fähigkeiten "und" Zusammenfassung der Verwendung von JavaScript Mathematical Operation Nutzung ""
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.