点击事件更换class,代码如何实现,谢谢 object.className [ = sClass ]onClick="this.className='pg'" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 TDthis.style.className='pg';TD{DefineTDOnMouseOver:expression(this.onmouseover=function(){this.className='pg';});DefineTDOnMouseOut:expression(this.onmouseout=function(){this.className='pg';});DefineTDOnClick:expression(this.onclick=function(){this.className='pg';});} <style>TD{DefineTDOnMouseOver:expression(this.onmouseover=function(){this.className='pg';});DefineTDOnMouseOut:expression(this.onmouseout=function(){this.className='pg';});DefineTDOnClick:expression(this.onclick=function(){this.className='pg';});}</style> 对不同的单元格命名不同的id,然后通过id改变他们的class<td width=76 id="tdchat" onclick="changePic() " class="pg" onMouseOver="this.className='pg'" onMouseOut="this.className='pg1'">聊天</td> <td width=76 id="tdsearch" class="pg1" onMouseOver="this.className='pg'" onMouseOut="this.className='pg1'" onClick="document.all.tdchat.className='pg1';document.all.tdsearch.className='pg'">查找</td> 给你个例子看看吧,不是td的,但是机制是一样的------------------<HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=gb2312"><STYLE>A.a2{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#000000;}A.a2:active{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#000000;}A.a2:link{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#000000;}A.a2:visited{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#000000;}A.a2:hover{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#FF0000;}/*设置未读取的超链接样式,用于esales主页部分*/A.a1{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#0000FF;}A.a1:active{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#0000FF;}A.a1:link{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#0000FF;}A.a1:visited{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:#0000FF;}A.a1:hover{ FONT-SIZE:12px; TEXT-decoration : underline; COLOR:red;}</STYLE><SCRIPT language="javascript">function chan(oObj,claName){ var arrObj = document.getElementsByName("n"); for(var i=0; i<arrObj.length; i++) arrObj[i].className = arrObj[i].preCss; oObj.className = claName;}function init(){ var arrObj = document.getElementsByName("n"); for(var i=0; i<arrObj.length; i++) { arrObj[i].preCss = arrObj[i].className; } arrObj[0].className = "a2";}</SCRIPT></HEAD><BODY onLoad="init()"><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接1</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接2</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接3</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接4</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接5</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接6</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接7</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接8</A><A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接9</A></BODY></HTML> JS的同步问题? 逻辑运算符&&的用法 jquery怎样实现限制textarea字数 ie与Firefox间的关于session会话的兼容问题 有谁了解啊? 正则 请问怎样匹配最后一个</div> 紧急,关于网页显示图片大小自适应调整 frameset框架组成的html在ie中点击右上角“关闭”按钮和点击“退出”链接的问题 一个查找字符串的正则表达式 gridpanel某一列可编辑和某一列加复选框 有没有前端大神 解释一下 jquery datatable function里面的 a, b, c, d 是怎么赋值的 javascript中如何调用javabean? 高手请进来,(附源代码)
TD{DefineTDOnMouseOver:expression(this.onmouseover=function(){this.className='pg';});DefineTDOnMouseOut:expression(this.onmouseout=function(){this.className='pg';});DefineTDOnClick:expression(this.onclick=function(){this.className='pg';});}
TD{DefineTDOnMouseOver:expression(this.onmouseover=function(){this.className='pg';});DefineTDOnMouseOut:expression(this.onmouseout=function(){this.className='pg';});DefineTDOnClick:expression(this.onclick=function(){this.className='pg';});}
</style>
<td width=76 id="tdchat" onclick="changePic() " class="pg" onMouseOver="this.className='pg'" onMouseOut="this.className='pg1'">聊天</td>
<td width=76 id="tdsearch" class="pg1" onMouseOver="this.className='pg'" onMouseOut="this.className='pg1'" onClick="document.all.tdchat.className='pg1';document.all.tdsearch.className='pg'">查找</td>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE>
A.a2
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#000000;
}
A.a2:active
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#000000;
}
A.a2:link
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#000000;
}
A.a2:visited
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#000000;
}
A.a2:hover
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#FF0000;
}/*设置未读取的超链接样式,用于esales主页部分*/
A.a1
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#0000FF;
}
A.a1:active
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#0000FF;
}
A.a1:link
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#0000FF;
}
A.a1:visited
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:#0000FF;
}
A.a1:hover
{
FONT-SIZE:12px;
TEXT-decoration : underline;
COLOR:red;
}</STYLE>
<SCRIPT language="javascript">
function chan(oObj,claName)
{
var arrObj = document.getElementsByName("n");
for(var i=0; i<arrObj.length; i++)
arrObj[i].className = arrObj[i].preCss;
oObj.className = claName;
}
function init()
{
var arrObj = document.getElementsByName("n");
for(var i=0; i<arrObj.length; i++)
{
arrObj[i].preCss = arrObj[i].className;
}
arrObj[0].className = "a2";
}
</SCRIPT>
</HEAD><BODY onLoad="init()">
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接1</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接2</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接3</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接4</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接5</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接6</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接7</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接8</A>
<A name="n" class="a1" href="#" onClick="chan(this,'a2')">链接9</A>
</BODY>
</HTML>