Hi, I'm trying to create a Youtube video inserter script for my site. Long story short, I need to be able to prototype an HTML element and add a string into the element's innerHTML, like this: myObj.insertVid(5sw2OvIgoO8);
I'm using jQuery to getElementsByClass("sip").
Object.prototype.insertVid = function(id) {
if (id.length > 0) {
var insert_string = '<embed src="http://www.youtube.com/v/' + id + '&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"/>';
this.innerHTML += insert_string;
}
}
embeds = $(".sip");
for (var i=0; i<embeds.length; i++) {
// various code to find param for insertVid()
embeds[i].insertVid(id);
}
All of this code seems correct to me, but in the error console (Firefox 3.5.2), it's telling me: Error: embeds[i].insertVid is not a function
Help?