gpt4 book ai didi

javascript - 在html元素中显示Jquery数据

转载 作者:行者123 更新时间:2023-12-02 18:56:45 24 4
gpt4 key购买 nike

这会从文本文件中获取文本并显示它,每五秒刷新一次。我希望文本以公告横幅样式在屏幕上滚动。选取框只是一个占位符,我该如何做呢?

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Raffle Winers</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="jquery.marquee.js"></script>
<style type="text/css">
body {
margin: 10px;
font-family: 'Lato', sans-serif;
}
small {
font-size: 14px;
}
h1 {
margin-bottom: 20px;
padding-bottom: 10px;
text-align: center;
}

h2 {
border-bottom: 1px dotted #ccc;
padding-bottom: 5px;
margin-bottom: 10px;
}

.marquee, .marquee-with-options {
width: 300px;
overflow: hidden;
border:1px solid #ccc;
}
</style>
<script>
$(function(){
var $mwo = $('.marquee-with-options');
$('.marquee').marquee();
$('.marquee-with-options').marquee({
//speed in milliseconds of the marquee
speed: 5000,
//gap in pixels between the tickers
gap: 50,
//gap in pixels between the tickers
delayBeforeStart: 0,
//'left' or 'right'
direction: 'left',
//true or false - should the marquee be duplicated to show an effect of continues flow
duplicated: true,
//on hover pause the marquee - using jQuery plugin https://github.com/tobia/Pause
pauseOnHover: true
});

//pause and resume links
$('.pause').click(function(e){
e.preventDefault();
$mwo.trigger('pause');
});
$('.resume').click(function(e){
e.preventDefault();
$mwo.trigger('resume');
});
//toggle
$('.toggle').hover(function(e){
$mwo.trigger('pause');
},function(){
$mwo.trigger('resume');
})
.click(function(e){
e.preventDefault();
})
});
</script>

</head>
<body>

<script type="text/javascript">
setInterval(read,100);
function read(){
jQuery.get('rafflewinners.txt',function(data){$('#container').html(data);});
}
</script>

<div id="container"></div>


<div id="container" data-speed="2000" data-gap="30" data-direction="right" class='marquee'>#container</div>

</body>

最佳答案

如果 DIV 的内容在初始化后发生更改,选取框插件将停止工作。您必须重新启动它。

function read(){
jQuery.get('rafflewinners.txt',function(data){
$('#container').html(data).marquee();
});
}

查看此fiddle

关于javascript - 在html元素中显示Jquery数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15262247/

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