还是老话,不要直接在html中写js代码
修改input,onclick事件,点击后,submit变灰
<form action="http://www.baidu.com" method="POST"> <input name="T1" size="20" type="text" /> <input onclick="javascript:{this.disabled=true;document.form1.submit();}" type="button" value="提交" /> <input name="B2" type="reset" value="重置" /> </form>
鼠标划过,变色!
<table border="1" width="200"> <tbody> <tr onmouseover="this.bgColor='#666666'" onmouseout="this.bgColor='#FFFFFF'"> <td>1</td> </tr> <tr onmouseover="this.bgColor='#666666'" onmouseout="this.bgColor='#FFFFFF'"> <td>2</td> </tr> </tbody> </table>
鼠标选定后改变input的value值
<input id="q" type="text" value="Search" style="color:#ccc" onblur="if(this.value=='') {this.value='Search';this.style.color='#ccc';}" onfocus="if(this.value=='Search') {this.value='';}this.style.color='#333';" />