是的,我在这里查看槽相同的文章,谷歌帮助。但我是一名设计师,而不是编码员。我可以复制\粘贴一些代码,甚至改变一些东西,但这个问题对我来说太难了。jquery代码无法在ajax加载的内容中工作
所以,我在我的主页上有新闻,当你向下滚动时,下一页加载ajax。有一个脚本,为每个帖子显示\隐藏评级栏。但是这个代码在加载的内容中不起作用。请修复它,如果它不适合你。
p.s.我尝试着看(),或者活下去,但是因为我以前难过,而不是我的水平。
$(document).ready(function() {
var element = $('#dle-content .main-news');
for (i=0; i<element.length; i++)
{
$(element[i]).addClass('news-'+i);
}
$('#dle-content .main-news').hover(
function() {
$('.main-news-hidden').stop(true);
$(this).find('.main-news-hidden').animate({
'bottom':'0'
},400
);
}, function() {
$('.main-news-hidden').stop(true);
$(this).find('.main-news-hidden').animate({
'bottom':'-120'
}, 0);
$('.main-news-hidden').stop(true);
});
$('.top-news li').hover(
function() {
$('.top-news-hidden').stop(true).fadeOut(0);
$(this).find('.top-news-hidden').animate({
'opacity':'1'
},400, function()
{
$(this).fadeIn();
}
);
}, function() {
$('.top-news-hidden').stop(true);
$(this).find('.top-news-hidden').fadeOut(100);
});
var element2 = $('.top-news li');
for (i=0; i<element2.length; i++)
{
$(element2[i]).find('.list').append(i+1);
}
});
非常感谢,解决方案3的帮助。这是代码,很好用。 $( “#内容”)。鼠标指向(函数(){\t \t \t $(”。主新闻)。悬停( \t \t功能(){ \t \t \t $(本).find( ”。主要新闻隐藏 ')停止()动画({ \t \t \t \t '底部':' 0' \t \t \t},400 \t \t \t); \t \t},闪光功能。重刑(){ \t \t \t $(本).find(”主新闻隐藏。 ')停止()动画({ \t \t \t \t '底部':' - 135' \t \t \t}。 ,300 \t \t \t); \t}); }); – noid