我想用.load()函数加载一些内容,这里是我的代码。jQuery变量问题
$(window).load(function() {
$('.spotlight').append('<div class="caption"></div>');
$('.spotlight .caption').hover(function() {
$(this).animate({ top : '-=50px' }, 150)}, function() {
$(this).animate({ top : '+=50px' }, 150)}
);
$('.caption').load($(this).parent().data('who')+'.html');
});
但在HTML我有
<div class="spotlight" who="student">
<img src="sga_small.jpg" />
</div>
<div class="spotlight" who="staff">
<img src="sga_small.jpg" />
</div>
但它试图在undefined.html加载。我将如何去解决这个问题? 这里到页面的链接http://www.coralspringshigh.org/demo/
你能不能给我们,您拨打电话'.load()'整个事件?它很难知道什么'this'没有该函数的上下文... – gnarf 2011-03-11 05:40:08
你可以粘贴完整的HTML与元素有标题类 – 2011-03-11 05:41:20
对不起,添加了其余的代码。 – Koalatea 2011-03-11 05:53:57