javascript - jquery return value of a non-existing id or class? -
i need check if object has same id on dom, because trying create modal window library,
the problem in browsers console when write
$("#anonexistingid");
it returns []
but in code
if($("#"+id)!==[]){ return; }
just not work. proper way of defining empty array?(because think [] means empty array, maybe not not sure :d)
jquery returns object. can check it's length see if it's empty or not:
if($("#"+id).length !== 0){ }
Comments
Post a Comment