gpt4 book ai didi

php - 如何在没有任何人工交互(即单击等)的情况下使用 JQuery .live()?

转载 作者:行者123 更新时间:2023-12-01 08:20:42 26 4
gpt4 key购买 nike

这是我的代码,它自动刷新包含从 Twitter 中提取的推文的 div:

var twittercacheData;
var twitterdata = $('#bottom-bar').html();
var twitterauto_refresh = setInterval(
function ()
{
$.ajax({
url: 'twitter.php',
type: 'POST',
data: twitterdata,
dataType: 'html',
success: function(twitterdata) {
if (twitterdata !== twittercacheData){
//data has changed (or it's the first call), save new cache data and update div
twittercacheData = twitterdata;
$('#bottom-bar').fadeOut("slow").html(twitterdata).fadeIn("slow");
}
}
})
}, 60000); // check every minute - reasonable considering time it takes 5 tweets to scroll across

唯一的事情是在 twitter.php 中我这样做:

// initialise the marquee plugin so that we get a nice smooth scrolling effect
$('div.twitter marquee').marquee();

所以实际上我正在拉推文并将它们插入字幕并初始化 Remy Shaprp 的选取框插件,因为 div 正在刷新,我认为选取框插件在初始刷新后没有被初始化,因为在第一次刷新后工作完美,firebug 报告:

marqueeState 未定义

我研究过使用 .live() 但不知道要使用哪种事件类型,因为我想不出不需要用户交互的事件类型。

有什么想法吗?

最佳答案

我会使用livequery插件并执行如下操作:

$('div.twitter marquee').livequery(function() {
$(this).marquee();
});

或者您可以使用custom events与 .live()。

关于php - 如何在没有任何人工交互(即单击等)的情况下使用 JQuery .live()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7532096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com