100′求一个button特效 等ing……

尐孑 2008-08-08 10:26:20

有N个button 也就是说button的个数不定,
当点击一个button时,此button的样式变为突出或改变背景色
其他的样式还原为初始样式。
...全文
128 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingcsx666 2008-08-08
  • 打赏
  • 举报
回复
楼上正解
尐孑 2008-08-08
  • 打赏
  • 举报
回复
放在我这里怎么不行啊
oec2003 2008-08-08
  • 打赏
  • 举报
回复

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="testjavascript.WebForm1" %>

<!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><title></title>
<style type="text/css">
.buttonBorder{ border:1px solid red;}
</style>

</head>
<body>
<form id="form1" runat="server">
<input type="button" value="button1" onclick="changeColor(this)"/>
<input type="button" value="button2" onclick="changeColor(this)"/>
<input type="button" value="button3" onclick="changeColor(this)"/>
<input type="button" value="button4" onclick="changeColor(this)"/>
<input type="button" value="button5" onclick="changeColor(this)"/>
</form>

<script type="text/javascript">

function changeColor(obj)
{
var inputs=document.getElementById("form1").getElementsByTagName("input");
for(var i=0;i<inputs.length;i++)
{
if(inputs[i].type=="button")
{
inputs[i].style.borderColor="";
}
}
obj.style.borderColor="red";
}

</script>
</body>

</html>

czhiyong_153650 2008-08-08
  • 打赏
  • 举报
回复
楼上正解
greystar 2008-08-08
  • 打赏
  • 举报
回复
document.getElementsByTagName("input")
greystar 2008-08-08
  • 打赏
  • 举报
回复
js来处理

<input type=button id="d1" onclick="changecolor(this.id);">
<input type=button id="d2" onclick="changecolor(this.id);">
<input type=button id="d3" onclick="changecolor(this.id);">
<input type=button id="d4" onclick="changecolor(this.id);">
<input type=button id="dn" onclick="changecolor(this.id);">


function changecolor(id)
{
var bs=document.getElementbytag("input");
for(i=0;i<bs.length;i++)
{
if(bs[i].type="button")
{
if(bs[i].id==id)
//这个是你当前处理的.
bs[i].style.xxxx=xxxx;
else
{
bs[i].style.xxxx=默认的;
}

}
}
}
尐孑 2008-08-08
  • 打赏
  • 举报
回复
我加上alert 试了 在我这根本就不执行

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧