To check if a element exists in Javascript you can use the following snippet.
Sample Javascript
if (document.getElementById("elementid")) { //element exists }
Sample jQuery
if ($("#elementid").length) { //element exists }
All the Code Snippets and Samples you need
To check if a element exists in Javascript you can use the following snippet.
if (document.getElementById("elementid")) { //element exists }
if ($("#elementid").length) { //element exists }
You must be logged in to post a comment.
RT @CodeSnippetsNET: How to check if a element exists in #js / #Javascript / #jQuery http://t.co/DQAnTXZf65
RT @CodeSnippetsNET: How to check if a element exists in #js / #Javascript / #jQuery http://t.co/DQAnTXZf65