文本框边框色效果

本文介绍了一种使用HTML和JavaScript结合的方式来自定义输入框的样式变化效果。当鼠标悬停或获得焦点时,输入框边框颜色变为红色;失去焦点或鼠标移出时,若未获得焦点则恢复默认边框颜色。此方法适用于网页表单元素的美化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<style>
input {border:#565656 1px solid;height:20px;line-height:19px;vertical-align:middle;font-size:12px;color:#565656;}
</style>
<script>
function fEvent(sType,oInput){
switch (sType){
case "focus" :
oInput.isfocus = true;
case "mouseover" :
oInput.style.borderColor = '#f00';
break;
case "blur" :
oInput.isfocus = false;
case "mouseout" :
if(!oInput.isfocus){
oInput.style.borderColor='#565656';
}
break;
}
}
</script>
<form name="form1" method="post" action="search.asp" target="_blank">
搜索:<br/>
名称:
<input type="text" name="name" onmouseover="fEvent('mouseover',this)" onfocus="fEvent('focus',this)" onblur="fEvent('blur',this)" onmouseout="fEvent('mouseout',this)"><br/>
编号:
<input type="text" name="num" onmouseover="fEvent('mouseover',this)" onfocus="fEvent('focus',this)" onblur="fEvent('blur',this)" onmouseout="fEvent('mouseout',this)"><br/>
<br/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值