簡體   English   中英

UL中列表項的隨機(項目符號)圖像?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM