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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -