泓泰

html点击文字变色 再次点击就恢复点击前的颜色,首次点击改变颜色再次点击或点击恢复颜色

admin

本文目录一览

html点击文字变色 再次点击就恢复点击前的颜色

你用下面的代码试试,怎么可能没反应,我测试都通过了:

style type="text/css"
.over {color:#000000; background: #fcc546}
.down {color:#000000; background: #fcc444; font-style: italic}
/style
table id="Table3"
tr
td align="middle" bgcolor="#fefef5" class="noball" onclick="chg(this); " width="25" aaa
/td
tr
/table

script type="text/javascript"
function chg(obj){
if(obj.className != "over"){
obj.oldClass = obj.className; // 暂存原来的class,用于恢复
obj.className = "over";
}else if(obj.oldClass){
obj.className = obj.oldClass; // 暂存原来的class,用于恢复
}
}
/script

急!!求大神,jquery怎么做点击背景颜色变,再点击再恢复

!DOCTYPE?html
html
??head
meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8"
script?class="jquery?library"?src="/js/sandbox/jquery/jquery-1.8.2.min.js"?type="text/javascript"/script
title
RunJS?演示代码
/title
script
$(function(){
$("div").toggle(function(){
$(this).css("backgroundColor","red");
},function(){
$(this).css("backgroundColor","blue");
});
})
/script
??/head
body
????div?style="background-color:blue"
sdfsdf
/div
??/body
/html

标签: #html点击文字变色 再次点击就恢复点击前的颜色#首次点击改变颜色再次点击或点击恢复颜色