gpt4 book ai didi

javascript - 推特小部件包装问题

转载 作者:行者123 更新时间:2023-11-28 14:10:50 25 4
gpt4 key购买 nike

我在我的网站上创建了一个实时推文提要,其中包含一个轮播。我面临的挑战是将 twitter API 提要 div 转换为“li's”,以便每个 twitter 提要都显示在单独的 li 中。

click here

我一直在阅读以下内容;

http://api.jquery.com/wrap/

但是我发现它很难消化。这个论坛中有没有人可以分解实现这一目标的开发过程?

谢谢

最佳答案

我帮助解决了你的其他问题,所以我假设你想将它应用到同一个 url - http://thisiswired.com/test/test.html

如果是这种情况,您可以使用以下代码:

// Remove unwanted div
$('.twtr-reference-tweet').remove();

// Change the <div>s to <li>s
$('.twtr-tweet').each(function() {
$(this).replaceWith('<li id="'+$(this).attr('id')+'" class="'+$(this).attr('class')+'">' + $(this).html() + '</li>');
});

// Change the parent <div> to <ul> and wrap it in a <div> ready to apply the carousel
$('.twtr-tweets').replaceWith('<div id="carouselId"> <ul class="twtr-tweets">'+$('.twtr-tweets').html()+'</ul></div>');

已排序!

关于javascript - 推特小部件包装问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9516389/

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