matt
matt

Reputation: 44403

Get ID of dom-element

console.log(video);

puts in my console the following line:

<object type=​"application/​x-shockwave-flash" class=​"video" data=​"http:​/​/​www.youtube.com/​v/​vyFAF-J3jzM" width=​"308" height=​"100" id=​"video" style=​"visibility:​ visible;​ ">​…​</object>

So "video" holds the entire dom-object. How can I query the ID of this object with JavaScript?

Something like var vidID = video.getId();

Upvotes: 45

Views: 106440

Answers (3)

duncmc
duncmc

Reputation: 968

How about…

var vidID = video.id;

…?

Upvotes: 12

jondavidjohn
jondavidjohn

Reputation: 62412

It's simply video.id ........

Upvotes: 69

The Scrum Meister
The Scrum Meister

Reputation: 30131

var videoElement = document.getElementById('video');
var idOfElement = videoElement.getAttribute('id');

Upvotes: 45

Related Questions