我正在使用此插件:http://www.jquerynewsticker.com/
我需要将li的内容包含在<a href=""></a>
<ul id="js-news">
<li class="news-item">This is text 1 ...</li>
<li class="news-item">This is text 2 ...</li>
<li class="news-item">This is text 3 ...</li>
<li class="news-item">This is text 4 ...</li>
</ul>
像这样:
<ul id="js-news">
<li class="news-item"><a href="my-form">This is text 1 ...</a></li>
<li class="news-item"><a href="my-form">This is text 2 ...</a></li>
<li class="news-item"><a href="my-form">This is text 3 ...</a></li>
<li class="news-item"><a href="my-form">This is text 4 ...</a></li>
</ul>
我认为字符串需要在这个中。但我不知道如何:
script type="text/javascript">
$(function () {
$('#js-news').ticker({
});
});
</script>
答案 0 :(得分:4)
试试这个:
$('li.news-item').each(function(){
$(this).contents().wrap('<a href="#"/>');
});
答案 1 :(得分:1)