首页 > 编程 > JavaScript > 正文

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

2019-11-20 23:32:22
字体:
来源:转载
供稿:网友
首先建一个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 参考手册 - 事件
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表