JS實(shí)現(xiàn)的表格行鼠標(biāo)點(diǎn)擊高亮效果代碼
本文實(shí)例講述了JS實(shí)現(xiàn)的表格行鼠標(biāo)點(diǎn)擊高亮效果代碼。分享給大家供大家參考,具體如下:
偶爾在看天天基金網(wǎng)凈值公告時(shí),從源代碼里剝下的一段js代碼,感覺比較實(shí)用,分享一下(僅IE有效)
<script type="text/javascript">
var highlightcolor='#E0F2FE';
var clickcolor='#ffedd2';
function MouseOver(){
var source=event.srcElement;
if (source.tagName=="TD"){
source=source.parentElement;
var cells = source.children;
if (cells[0].style.backgroundColor!=highlightcolor&&cells[0].style.backgroundColor!=clickcolor)
for(i=0;i<cells.length;i++){
cells[i].style.backgroundColor=highlightcolor;
}
}
}
function MouseOut(){
var source=event.srcElement;
if (source.tagName=="TD"){
source=source.parentElement;
var cells = source.children;
if (cells[0].style.backgroundColor!=clickcolor)
for(i=0;i<cells.length;i++){
cells[i].style.backgroundColor="";
}
}
}
function MouseClick(){
var source=event.srcElement;
if (source.tagName=="TD"){
source=source.parentElement;
var cells = source.children;
if (cells[0].style.backgroundColor!=clickcolor)
for(i=0;i<cells.length;i++)
cells[i].style.backgroundColor=clickcolor;
else
for(i=0;i<cells.length;i++)
cells[i].style.backgroundColor="";
}
}
</script>
<table onmouseover="MouseOver()" onclick="MouseClick()" onmouseout="MouseOut()" cellspacing="0" bordercolordark="#ffffff" bordercolorlight="#cccccc" border="1" width="80%" align="center" style="cursor:pointer">
<tr>
<td>1</td>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td>2</td>
<td>c</td>
<td>d</td>
</tr>
<tr>
<td>3</td>
<td>e</td>
<td>f </td>
</tr>
<tr>
<td>4</td>
<td>g</td>
<td>h </td>
</tr>
</table>
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
- js實(shí)現(xiàn)當(dāng)鼠標(biāo)移到表格上時(shí)顯示這一格全部?jī)?nèi)容的代碼
- 基于JS代碼實(shí)現(xiàn)當(dāng)鼠標(biāo)懸停表格上顯示這一格的全部?jī)?nèi)容
- js實(shí)現(xiàn)鼠標(biāo)經(jīng)過表格行變色的方法
- javascript表格隔行變色加鼠標(biāo)移入移出及點(diǎn)擊效果的方法
- JS實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊展開或隱藏表格行的方法
- 鼠標(biāo)拖動(dòng)動(dòng)態(tài)改變表格的寬度的js腳本 兼容ie/firefox
- 一個(gè)簡(jiǎn)單但常用的javascript表格樣式_鼠標(biāo)劃過行變色 簡(jiǎn)潔實(shí)現(xiàn)
- Javaweb 鼠標(biāo)移入移出表格顏色變化的實(shí)現(xiàn)
相關(guān)文章
關(guān)于include標(biāo)簽導(dǎo)致js路徑找不到的問題分析及解決
本文為大家詳細(xì)介紹下關(guān)于使用jsp:include標(biāo)簽及<%@ include標(biāo)簽時(shí)要注意的事項(xiàng)以及實(shí)測(cè)發(fā)現(xiàn)問題并解決問題的全過程,感興趣的各位可以參考下哈,希望對(duì)大家有所幫助2013-07-07
基于JS實(shí)現(xiàn)發(fā)送驗(yàn)證碼的計(jì)時(shí)器效果
這篇文章主要為大家詳細(xì)介紹了如何基于JS實(shí)現(xiàn)一個(gè)發(fā)送驗(yàn)證碼的計(jì)時(shí)器效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴快跟隨小編一起學(xué)習(xí)一下吧2023-11-11
帶領(lǐng)大家學(xué)習(xí)javascript基礎(chǔ)篇(一)之基本概念
這篇文章主要介紹了帶領(lǐng)大家學(xué)習(xí)javascript基礎(chǔ)篇(一)之基本概念的相關(guān)資料,需要的朋友可以參考下2015-11-11
使用JavaScript實(shí)現(xiàn)ajax的實(shí)例代碼
實(shí)現(xiàn)ajax之前必須要?jiǎng)?chuàng)建一個(gè) XMLHttpRequest 對(duì)象。這是必須的。那么對(duì)使用js實(shí)現(xiàn)ajax的代碼感興趣的朋友可以參考下本文2016-05-05
javascript產(chǎn)生隨機(jī)數(shù)方法匯總
這篇文章主要介紹了javascript產(chǎn)生隨機(jī)數(shù)方法匯總的相關(guān)資料,需要的朋友可以參考下2016-01-01

