JS+CSS實(shí)現(xiàn)Li列表隔行換色效果的方法
更新時(shí)間:2015年02月16日 12:18:29 作者:代碼家園
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)Li列表隔行換色效果的方法,實(shí)例分析了js操作li節(jié)點(diǎn)的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了JS+CSS實(shí)現(xiàn)Li列表隔行換色效果的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS+Js實(shí)現(xiàn)Li列表隔行換色效果</title>
</head><body>
<style>
.mytable {border-collapse:collapse;border:solid #6AA70B;border-width:0px 0 0 0px;width:50%;}
.mytable ul li {padding-top:5px;text-indent:2em;list-style:none;background:url(/images/20110704/new_dot.gif) 3px 50% no-repeat;border-bottom:#6AA70B 1px dotted ;font-family: "Verdana,宋體";font-size: 12px;color:#008000;text-align:left;height:25px;}
.mytable ul li.t1 {background-color:#EFFEDD;}
.mytable ul li.t2{background-color:#ffffff;}
.mytable ul li.t3 {background-color:#D2FCA0;}
</style>
<body style=margin:0;><br><br><br>
<div align="center">
<div class=mytable id=tab>
<ul>
<li>
<a title="JavaScript實(shí)現(xiàn)文字與圖片拖拽效果的方法" target="_blank" href="http://www.dhdzp.com/article/61182.htm">
JavaScript實(shí)現(xiàn)文字與圖片拖拽效果的方法</a></li>
<li>
<a title="jQuery實(shí)現(xiàn)點(diǎn)擊圖片翻頁展示效果的方法" target="_blank" href="http://www.dhdzp.com/article/61181.htm">
jQuery實(shí)現(xiàn)點(diǎn)擊圖片翻頁展示效果的方法</a></li>
<li>
<a title="php實(shí)現(xiàn)遞歸與無限分類的方法" target="_blank" href="http://www.dhdzp.com/article/61180.htm">
php實(shí)現(xiàn)遞歸與無限分類的方法</a></li>
<li>
<a title="php實(shí)現(xiàn)多維數(shù)組中每個(gè)單元值(數(shù)字)翻倍的方法" target="_blank" href="http://www.dhdzp.com/article/61179.htm">
php實(shí)現(xiàn)多維數(shù)組中每個(gè)單元值(數(shù)字)翻倍的方法</a></li>
<li>
<a title="php數(shù)組添加與刪除單元的常用函數(shù)實(shí)例分析" target="_blank" href="http://www.dhdzp.com/article/61178.htm">
php數(shù)組添加與刪除單元的常用函數(shù)實(shí)例分析</a></li>
<li>
<a title="JS+CSS實(shí)現(xiàn)可拖動(dòng)的彈出提示框" target="_blank" href="http://www.dhdzp.com/article/61177.htm">
JS+CSS實(shí)現(xiàn)可拖動(dòng)的彈出提示框</a></li>
<li>
<a title="js實(shí)現(xiàn)下拉框選擇要顯示圖片的方法" target="_blank" href="http://www.dhdzp.com/article/61176.htm">
js實(shí)現(xiàn)下拉框選擇要顯示圖片的方法</a></li>
<li>
<a title="js實(shí)現(xiàn)點(diǎn)擊圖片將圖片地址復(fù)制到粘貼板的方法" target="_blank" href="http://www.dhdzp.com/article/61175.htm">
js實(shí)現(xiàn)點(diǎn)擊圖片將圖片地址復(fù)制到粘貼板的方法</a></li>
</ul></div><script type="text/javascript">
<!--
var Ptr=document.getElementById("tab").getElementsByTagName("li");
function $() {
for (i=1;i<Ptr.length+1;i++) {
Ptr[i-1].className = (i%2>0)?"t1":"t2";
}
}
window.onload=$;
for(var i=0;i<Ptr.length;i++) {
Ptr[i].onmouseover=function(){
this.tmpClass=this.className;
this.className = "t3";
};
Ptr[i].onmouseout=function(){
this.className=this.tmpClass;
};
}
//-->
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS+Js實(shí)現(xiàn)Li列表隔行換色效果</title>
</head><body>
<style>
.mytable {border-collapse:collapse;border:solid #6AA70B;border-width:0px 0 0 0px;width:50%;}
.mytable ul li {padding-top:5px;text-indent:2em;list-style:none;background:url(/images/20110704/new_dot.gif) 3px 50% no-repeat;border-bottom:#6AA70B 1px dotted ;font-family: "Verdana,宋體";font-size: 12px;color:#008000;text-align:left;height:25px;}
.mytable ul li.t1 {background-color:#EFFEDD;}
.mytable ul li.t2{background-color:#ffffff;}
.mytable ul li.t3 {background-color:#D2FCA0;}
</style>
<body style=margin:0;><br><br><br>
<div align="center">
<div class=mytable id=tab>
<ul>
<li>
<a title="JavaScript實(shí)現(xiàn)文字與圖片拖拽效果的方法" target="_blank" href="http://www.dhdzp.com/article/61182.htm">
JavaScript實(shí)現(xiàn)文字與圖片拖拽效果的方法</a></li>
<li>
<a title="jQuery實(shí)現(xiàn)點(diǎn)擊圖片翻頁展示效果的方法" target="_blank" href="http://www.dhdzp.com/article/61181.htm">
jQuery實(shí)現(xiàn)點(diǎn)擊圖片翻頁展示效果的方法</a></li>
<li>
<a title="php實(shí)現(xiàn)遞歸與無限分類的方法" target="_blank" href="http://www.dhdzp.com/article/61180.htm">
php實(shí)現(xiàn)遞歸與無限分類的方法</a></li>
<li>
<a title="php實(shí)現(xiàn)多維數(shù)組中每個(gè)單元值(數(shù)字)翻倍的方法" target="_blank" href="http://www.dhdzp.com/article/61179.htm">
php實(shí)現(xiàn)多維數(shù)組中每個(gè)單元值(數(shù)字)翻倍的方法</a></li>
<li>
<a title="php數(shù)組添加與刪除單元的常用函數(shù)實(shí)例分析" target="_blank" href="http://www.dhdzp.com/article/61178.htm">
php數(shù)組添加與刪除單元的常用函數(shù)實(shí)例分析</a></li>
<li>
<a title="JS+CSS實(shí)現(xiàn)可拖動(dòng)的彈出提示框" target="_blank" href="http://www.dhdzp.com/article/61177.htm">
JS+CSS實(shí)現(xiàn)可拖動(dòng)的彈出提示框</a></li>
<li>
<a title="js實(shí)現(xiàn)下拉框選擇要顯示圖片的方法" target="_blank" href="http://www.dhdzp.com/article/61176.htm">
js實(shí)現(xiàn)下拉框選擇要顯示圖片的方法</a></li>
<li>
<a title="js實(shí)現(xiàn)點(diǎn)擊圖片將圖片地址復(fù)制到粘貼板的方法" target="_blank" href="http://www.dhdzp.com/article/61175.htm">
js實(shí)現(xiàn)點(diǎn)擊圖片將圖片地址復(fù)制到粘貼板的方法</a></li>
</ul></div><script type="text/javascript">
<!--
var Ptr=document.getElementById("tab").getElementsByTagName("li");
function $() {
for (i=1;i<Ptr.length+1;i++) {
Ptr[i-1].className = (i%2>0)?"t1":"t2";
}
}
window.onload=$;
for(var i=0;i<Ptr.length;i++) {
Ptr[i].onmouseover=function(){
this.tmpClass=this.className;
this.className = "t3";
};
Ptr[i].onmouseout=function(){
this.className=this.tmpClass;
};
}
//-->
</script>
</body>
</html>
希望本文所述對大家的javascript程序設(shè)計(jì)有所幫助。
相關(guān)文章
七個(gè)基于JavaScript實(shí)現(xiàn)的情人節(jié)表白特效
情人節(jié)將至 程序員證明自己不是直男的時(shí)候到啦 我們也有自己的專屬代碼浪漫。本文將介紹七個(gè)利用JavaScript實(shí)現(xiàn)的情人節(jié)表白特效,需要的可以參考一下2022-01-01
如何通過IntersectionObserver實(shí)現(xiàn)懶加載
這篇文章主要介紹了通過IntersectionObserver實(shí)現(xiàn)懶加載,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-04-04
微信小程序基于數(shù)據(jù)庫時(shí)間實(shí)現(xiàn)商品倒計(jì)時(shí)功能(可重用代碼)
這篇文章主要介紹了微信小程序基于數(shù)據(jù)庫時(shí)間實(shí)現(xiàn)商品倒計(jì)時(shí)功能(可重用代碼),代碼很完整,拿來就可以使用,現(xiàn)在我把完整的代碼分享給大家,需要的朋友可以參考下2022-07-07
移動(dòng)端基礎(chǔ)事件總結(jié)與應(yīng)用
本文主要介紹了移動(dòng)端基礎(chǔ)事件總結(jié)與應(yīng)用,具有一定的參考價(jià)值,下面跟著小編一起來看下吧2017-01-01
JavaScript實(shí)現(xiàn)動(dòng)態(tài)增刪表格的方法
本篇文章主要介紹了JavaScript實(shí)現(xiàn)動(dòng)態(tài)增刪表格,可以實(shí)現(xiàn)表格增加和刪除數(shù)據(jù)的功能,非常具有實(shí)用價(jià)值,有興趣的可以了解一下2017-03-03

