日期:2014-05-18 浏览次数:20647 次
<%@ 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>