Dri*_*ood 2 css wordpress jquery
我有一个从wordpress帖子生成的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>
Run Code Online (Sandbox Code Playgroud)
jsFiddle链接显示它正在应用:http://www.jsfiddle.net/bradchristie/yxZ4m/