jquery Iframe src attribute

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2011-02-12T07:15:15Z Indexed on 2011/02/12 7:25 UTC
Read the original article Hit count: 133

Filed under:
|
|

Why does x alerts undefined for iframe but works for embed. I'm grabbing the iframe or embed code from a textarea

<iframe src="http://www.youtube.com/embed/9kiWvkj2ldWiU?hd=1"></iframe>

var textarea = $('#embedModal textarea'),
textareaValue = textarea.val(),
$embed = $($(textareaValue).find('iframe')),
x = $embed.attr('src');
alert(x); //alerts undefined for iframe

If you change find('iframe') to find('embed') and you try with the below embed code. then i'm able to get the value of src, but with iframe i get undefined. Seems strange.

<embed src="http://www.youtube.com/embed/9kiWvkj2ldWiU?hd=1"></embed>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about iframe