我想做个按钮点他他变黑再点他一次他变白再点一次又变黑这样反复 用js或者jq怎么做 这个想了好久不回 我是个初学者~~~ 一定要是js或者jq的代码啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script type="text/javascript"> function change(){ var a=document.getElementById("test"); var t=a.getAttribute("num"); if(t=="1"){ a.style.backgroundColor="black"; a.style.color="white"; }else{ a.style.backgroundColor="white"; a.style.color="black"; } a.setAttribute("num",-t); }</script></head><body><input type="button" num="1" id="test" style="background-color:#FFF; color:#000" value="test" onclick="change()"></body>这样试试 <!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">input.white { background-color:white; }input.black { background-color:black; color:white; }</style><script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script><script type="text/javascript">$(document).ready( function() { $("#btn").addClass('white').toggle(function() { $(this).removeClass("white").addClass("black"); }, function() { $(this).removeClass("black").addClass("white"); });});</script></head><body><input type="button" id="btn" value="我是按钮" /></body></html> jquery ajax同步提交的问题 高手帮忙看下,我的javascript方法怎么不执行 用快捷键ctrl+enter实现换行 菜鸟来请假,自动刷新指定框架问题。 帮我分析下这段代码,顺便教教我用帮助文档 求一个验证日期的方法(具体内详) 如何在javascript中启动exe程序? 急,网页可以打开本地的一个可执行文件吗? 怎么样刷新上一页面??? Js新手自学问题,请大家指点一下! 求DOM二级范围详解! JQuery 在循环中设置事件,最后一个覆盖了前面所有的设置,求解决办法.
function change(){
var a=document.getElementById("test");
var t=a.getAttribute("num");
if(t=="1"){
a.style.backgroundColor="black";
a.style.color="white";
}else{
a.style.backgroundColor="white";
a.style.color="black";
}
a.setAttribute("num",-t);
}
</script>
</head><body>
<input type="button" num="1" id="test" style="background-color:#FFF; color:#000" value="test" onclick="change()">
</body>
这样试试
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
input.white { background-color:white; }
input.black { background-color:black; color:white; }
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#btn").addClass('white').toggle(function() { $(this).removeClass("white").addClass("black"); }, function() { $(this).removeClass("black").addClass("white"); });
});
</script>
</head><body>
<input type="button" id="btn" value="我是按钮" />
</body>
</html>