I'm displaying data to marquee
using jQuery ajax.
When the ajax load (every 1 second), the data always show double.
Code:
var messageLen = jsonStr.message.length;
for(var i=0; i<messageLen; i++)
{
var message = jsonStr.message[i];
var newOption = $('<li>'+message+'</li>');
$('#list').append(newOption);
}
HTML
<marquee>
<ul id="list"></ul>
</marquee>
So, what I want the data show not double.
*I'm using $('#list').html(newOption);
it only show 1 data (actual I have more data)
Empty the list before loop
var messageLen = jsonStr.message.length;
$('#list').empty();
for(var i=0; i<messageLen; i++)
{
var message = jsonStr.message[i];
var newOption = $('<li>'+message+'</li>');
$('#list').append(newOption);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.