首页 > 语言 > JavaScript > 正文

jquery focus(fn),blur(fn)方法实例代码

2024-05-06 14:22:51
字体:
来源:转载
供稿:网友
首先建一个CSS样式表

.highlight{border: 1px solid #EFA100;outline: 2px solid #FFDC97;}

然后增加如下代码
代码如下:
<script type ="text/javascript" language ="javascript">
$(document).ready(function(){
$("input[type=text]").focus(function(){
$(this).addClass("highlight")
}).blur(function(){$(this).removeClass("highlight")});

});
</script>

jQuery 参考手册 - 事件
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选