I’ve an Image with attributes like name, width.
and now I’m trying to get an attribute value which is not existing with Image.
var title = imgTemp.attributes("Title").value;
And it is giving error, because argument Title is not there. How can I check this before assign?
You can use
getAttribute:If there is no title attribute, it will return
null.You can also access the attribute directly as a property:
It will then return an empty string if there is no title attribute present, which means that you will have the same return value if the title attribute is present but empty, f.ex:
<img title="">