Home  >  Article  >  Web Front-end  >  css application: click on the table to change the color of the clicked row

css application: click on the table to change the color of the clicked row

高洛峰
高洛峰Original
2016-11-24 15:03:051595browse

The code is as follows:

<script> 
function bgChange(obj) 
{ 
    objobj.bgColor=obj.bgColor==""?"#B6DC73":""; 
} 
</script> 
<table width="80%" border="1" bgcolor="#ffffcc"> 
    <tr onclick="bgChange(this)"> 
        <td>aa25.cn</td> 
        <td>aa25.cn</td> 
    </tr> 
    <tr onclick="bgChange(this)"> 
        <td>aa25.cn</td> 
        <td>aa25.cn</td> 
    </tr> 
    <tr onclick="bgChange(this)"> 
        <td>aa25.cn</td> 
        <td>aa25.cn</td> 
    </tr> 
</table>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn