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();
One of the most common methods to access an element in HTML DOM is getElementById() which accesses an element based on the value of its ID attribute. The value of the ID attributes are supposed to be unique and no two elements on a single HTML page should have similar IDs.
getElementById() is a quick way to access an element. Unlike the querySelector() method, the getElementById() is only available on the document object, not other elements. In this syntax, the id is a string that represents the id of the element to select. The id is case-sensitive.
id= labels the fields for use by JavaScript and Java DOM (Document Object Model). The names in name= must be unique within a form. The names in id= must be unique within the entire document.
It's simply video.id
........
var videoElement = document.getElementById('video'); var idOfElement = videoElement.getAttribute('id');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With