Identify Image
Moderator: General Moderators
Identify Image
Is it possible to identify image from ID/Name attributes? I tried, but I couldn't.
Re: Identify Image
Please clarify what you mean by "identify"
Re: Identify Image
Ok,
I have an ID/Name attribute of an element. And I need to identify whether it's image or not.
In case of other input elements, I can identify by the type.
I have an ID/Name attribute of an element. And I need to identify whether it's image or not.
In case of other input elements, I can identify by the type.
Re: Identify Image
Hmm...you could try tagName to see if it's "img".
Re: Identify Image
Ok, for example, I have an image element:
In javascript, I have only the ID attribute, ie. image.
But, How could I use the tagName to identify image from ID.
Can you give a line of code for this.
Code: Select all
<img src="a.gif" id="image">
But, How could I use the tagName to identify image from ID.
Can you give a line of code for this.
Re: Identify Image
How about
Code: Select all
if(document.getElementById('image').tagName == 'img')// it's an imageRe: Identify Image
Thanks jackpf, worked!!
Re: Identify Image
Cool 