how to find attributes of image by javascript -
i've image attributes name, width.
and i'm trying attribute value not existing image.
var title = imgtemp.attributes("title").value;
and giving error, because argument title
not there. how can check before assign?
you can use getattribute
:
var title = imgtemp.getattribute('title');
if there no title attribute, return null
.
you can access attribute directly property:
var title = imgtemp.title;
it return empty string if there no title attribute present, means have same return value if title attribute present empty, f.ex: <img title="">
Comments
Post a Comment