jquery select iframe with youtube embed src

為{幸葍}努か 提交于 2020-01-05 12:09:24

问题


If i want to select all youtube iframes via their src how can this be achieved, i have tried the jquery below but it won't work? the embed src is http://www.youtube.com/embed/videoid?rel=0

<script>
$('iframe[src="http://youtube.com/embed/"]')
</script>

回答1:


You need to write src^="..." to find <iframe>s with src that starts with ....




回答2:


First you need to write your script in jquery environment then you can use the attribute form in jquery.

$(document).ready(function(){
    var srcVAlue = $('iframe').attr('src');        
});


来源:https://stackoverflow.com/questions/8205584/jquery-select-iframe-with-youtube-embed-src

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!