silversurfer5150 — 2013-03-25T12:07:00-04:00 — #1
Does anyone know how to select a YouTube iframe with jQuery.
I am designing a player based on YouTube's js api and my plugin basically selects all of the iframes on a page and transforms then into custom YouTube players. It works ok but isn't suitable for websites that have other iframe content other than YouTube because the plugin will remove them indiscriminately and try to put the player in their place.
thanks in advance
jimmybrion — 2013-03-26T09:05:35-04:00 — #2
If possible try to add a code which will identified the iframe youtube content and neglect other iframe content.
var video = $(this);
var vidSrc = "";
vidSrc = video.attr('src');
silversurfer5150 — 2013-03-26T15:43:24-04:00 — #3
Thanks for your input, that's a good idea, my code actually does something similar already within the plugin but ideally I would like to select the YouTube video element before entering the plugin as in:
I have found various things like $("object"). (can't remember exact syntax) and suchlike which can select the child of an object tag but there doesn't appear to be much information about it.
pullo — 2013-03-26T16:11:12-04:00 — #4
Hi there silversurfer5150,
You can use the Attribute Starts With Selector
var youTubeIframes = $('iframe[src^="http://www.youtube.com/embed/"]');
silversurfer5150 — 2013-03-26T18:35:36-04:00 — #5
Thanks Pullo, that's a new selector to me, great