问题
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