appendchild element once if element present in js
//insert new Element after some reference Element
function insertAfter(newElement, referenceElement) {
referenceElement.parentNode.insertBefore(newElement, referenceElement.nextSibling);
}
//example usage
var newElement = document.createElement("div");
newElement.innerHTML = "my New Div Text";
var myCurrentElement= document.getElementById("myElementID");
insertAfter(newElement, myCurrentElement); <script>
var button = false;
function myfun(){
if ( button === false){
var b1 = document.createElement("BUTTON");
b1.innerHTML = "Click Me";
document.body.appendChild(b1);
return button = true;
}
}
</script>
<p id="demo" onclick="myfun();"> click me to create button </p>parentElement.insertBefore(newElement, parentElement.children[2]);
Also in JavaScript:
- Material-ui snowflake icon
- jquery select self and siblings
- jquery only number allowed to 10 digit
- jquery safely use $
- vue js cdn
- how to use redirect in react
- npm err! 503 service unavailable proxy
- jest input value
- how to add carousel in javascript
- call laravel route js
- angular guard redirect
- javascript array merge
- get input value on keypress jquery
- devexpress dxdatagrid custom text field link
- Prevent Multiple Form Submissions With JQuery
- check if a key exists in an object javascript
- js throttle function
- get unique id angular
- javascript submit a form with id
- reflection of an graph javascript
- javascript keypress backspace not working
- multiple conditions for JavaScript .includes() method
- jquery remove br from div
- int to string javascript