![](/img/trans.png)
[英]Take 3 random items from a ul and append to another list with random fadeIn and fadeOut
[英]Random (bullet) images for List Items in a UL?
我有一個從wordpost生成的ul li側欄。 客戶端為每個LI使用不同的圖像作為項目符號。 而不是手動添加單獨的項目符號,有沒有辦法從例如10個選項中進行選擇呢?
在想jQuery功能嗎? 有人做過嗎?
謝謝
也許像下面這樣:
<style type="text/css">
/* Add the styles here, incrementing the number of each one as you go (then change
the 3 in the jQuery addClass method so it corresponds with the number of options
available */
li.bullet-0 { list-style-type: circle; }
li.bullet-1 { list-style-type: disc; }
li.bullet-2 { list-style-type: square; }
</style>
<Script type="text/javascript">
$(document).ready(){
$('ul > li').each(function(i,e){
$(this).addClass('bullet-'+(i%3)); // change 3 to number of styles that are above.
});
});
</script>
jsFiddle鏈接以顯示其正在應用: http : //www.jsfiddle.net/bradchristie/yxZ4m/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.