How to check if a div exists with jQuery
27 Sep 2012The simple way to check if a div or element exists on the page using jQuery is to use the length
function
jQuery check div exists
if ($('ul.author').length)
{
//do xyz
}
Using plain Javascript you need check for the element using its ID
Javascript check div exists
if(document.getElementById("element_id") !== null)
{
//do xyz
}