JElster
asked on
document.querySelector - how to add and remove an element
Hi..
I can add an element using the following
var rect = document.createElement('di v');
var el = document.querySelector('.r esults').a ppendChild (rect);
How can I then remove it ?
I can add an element using the following
var rect = document.createElement('di
var el = document.querySelector('.r
How can I then remove it ?
el.parentNode.removeChild( el);
ASKER
How do I check if it exists and then remove it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How can I check the document, before I add it so I don't add it again.
This code will be in a click event
thx
This code will be in a click event
thx