如何在 jQuery 中找到所有链接(没有锚点)并将它们按照它们出现的顺序放在一个列表中。
例如:
Lorem ipsum dolor sit amet, consectetur adipiscing elit。Donec坐在 amet ipsum ut justo bakeum hendrerit ultricies。
所以,这将变成:
Lorem ipsum
坐下来,
肥胖精英。
坐 amet ipsum ut justo 发酵 hendrerit ultricies。
基本上我在我的网站上使用 embed.ly,所以当用户填写表格时,youtube/flickr 链接会自动出现在他创建它们的位置。我遇到的问题是 youtube 视频的缩略图似乎太大,并且无法正确切换(即我希望用户单击缩略图以显示视频)。(因此,例如,如果用户单击 dolar 链接,则 youtube 视频应出现在其下方,就像在 embed.ly 示例中一样)。
我在服务器端使用 php 和 php markdown。
embedly的查询代码如下:
<script type="text/javascript">
$(document).ready(function() {
$("a").embedly({}, function(oembed, dict){
if ( oembed == null)
alert("no embedly content found");
var output = "<a class='embedly' href='#'><img src='"+oembed.thumbnail_url+"' /></a><span>"+oembed.title+"</span>";
output += oembed['code'];
$(dict["node"]).parent().html( output );
});
var anchors = $("a"); anchors.embedly(); anchors.filter("[href*=flx.me]").addClass("googlenl");
$('a.embedly').live("click", function(e){
e.preventDefault();
$(this).parents('li').find('.embed').toggle();
});
});
</script>
我的网站在添加视频链接时生成的 html 是:
> <div id="content">
> <div class="youtube">
> <p><a class="embedly" href="#"><img
> src="phpForum_files/hqdefault.jpg"></a><span>UEFAChanpions
> League 2005-2006 RealMadrid vs Arsenal
> 2ndleg</span><div
> class="embed"><object height="360"
> width="640"><param name="wmode"
> value="opaque"><param name="movie"
> value="http://www.youtube.com/v/7aPGa9Gqj2c?fs=1"><param
> name="allowFullScreen"
> value="true"><param
> name="allowscriptaccess"
> value="always"><embed
> src="phpForum_files/7aPGa9Gqj2c.swf"
> type="application/x-shockwave-flash"
> allowscriptaccess="always"
> allowfullscreen="true" wmode="opaque"
> height="360"
> width="640"></object></div></p>
> </div> </div>
对不起,拉长的问题。干杯。