var div = document.createElement("div");
div.innerHTML = "demo";
document.body.appendChild(div);
alert(div.parentNode); //body element
document.body.removeChild(div);
alert(div.parentNode); //null
Web 2.0, Ruby, Rails, TDD, BDD,
rSpec, XMPP, BOSH, REST,
Javascript, Ajax, Google Maps API,
Google Gears API, CSS,
Java, C#, Social Network, RMagick, Nginx
Monday, May 12, 2008
Detecting whether the element exists in the browser if we have the reference of that element
Suppose you have a reference to an element and you want to make sure this element does exists on the browser document. You can detect this by checking the parentNode property of that element.
Labels:
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment