我是 jquery 的新手,我需要集成一些代码,我使用 .load() 函数从外部 html 文件调用它。那部分代码是一个包含视频和描述的.div。我需要做的就是让 fitVids 处理从外部文件加载的代码。
这是在 div.featured-container 中加载的 html:
<div class="featured-container">
<div class="container player clearfix">
<div class="span8 video-container">
<iframe width="600" height="338" src="http://www.youtube.com/embed/QkhqI49QeaM?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
<div class="span4 featured-content">
<div class="feat-meta">May 8, 2010 at 16:50 / by <a href="">Silviu Stefu</a></div>
<h2>Retiner - Mobile UI Kit</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse.
</p>
<a class="button-normal" href="">Read More...</a>
</div>
</div>
</div>
这是JS:
//load the first list item link
var firstLoad = $('.thumbnails li:nth-child(2) a').attr('href')+' .player';
$('.featured-container').load(firstLoad,'',showTheContent());
function showTheContent() {
$('.player').fitVids().fadeIn('slow');
}
//load the links on click
$('.thumbnails li a').click(function(){
var toLoad = $(this).attr('href')+' .player';
$('.player').fadeOut('slow',loadContent);
$('#load').remove();
$('#load').fadeIn('normal');
function loadContent() {
$('.featured-container').load(toLoad,'',showNewContent());
}
function showNewContent() {
$('.player').fadeIn('slow',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
那么,我应该在哪里放置 .fitVids() 函数以使 fideo 流畅?