为了账号安全,请及时绑定邮箱和手机立即绑定

交替颜色列表实现

标签:
JQuery

         现代浏览器通过CSS3方式,而ie6采用jquery实现: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>交替颜色列表的实现</title>
<style type="text/css">
ul
{
  margin:0;
  padding:0;
  list-style-type:none;
}
#ulist
{
  font-size:14px;
  line-height:1.5em;
  border-top:3px solid #119DBB;
  width:15em;
  margin:0 auto;
}
#ulist li
{
  background-color:#C9F1FA;
  cursor:pointer;
  padding-left:10px;
}
#ulist li:nth-child(odd)
{
  background-color:#FFF;
  border-top:1px dotted #14ADCD;
  border-bottom:1px dotted #14ADCD;
}
</style>
<!--[if IE 6]>    
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $('#ulist li:nth-child(odd)').css('background-color','#fff');
});
</script>
<![endif]-->
</head>

<body>
  <ul id="ulist">
    <li>这是一段测试用的文本</li>
    <li>这是一段测试用的文本</li>
    <li>这是一段测试用的文本</li>
    <li>这是一段测试用的文本</li>
    <li>这是一段测试用的文本</li>
    <li>这是一段测试用的文本</li>
  </ul>
</body>
</html>

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消