javascript - 推特小部件包装问题

标签 javascript jquery css twitter jcarousel

我在我的网站上创建了一个实时推文提要,其中包含一个轮播。我面临的挑战是将 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/

相关文章:

javascript - 为什么这个 jQuery 不向下滑动/显示隐藏(向上滑动)的元素?

javascript - DataTable 1.10.10 导出到 Excel 下载 zip 文件

javascript - Node.js 无法发送脚本?

javascript - JQuery empty() 方法如何工作?

javascript - 解析 KendoEditor TextArea 中的特殊字符

css - 尝试在三列页面中插入表格

javascript - jquery 中未删除的选项

jquery - 如何通过循环在ajax jquery中创建json数组并将其传递给rails Controller

accessibility - Apple VoiceOver 将单词作为首字母缩写词朗读。这个可以控制吗?

php - 如何在样式表 Wordpress 中链接背景图片?