扫码关注官方订阅号
名称:
.focus { border: 1px solid #f00; background:#CCC; }
当input字段获得焦点时,背景和边框都应该会有变化?为什么我的没有?求大神们指点
ringa_lee
应该是两个script标签吧
<script src="jquery-1.9.1.js" type="text/javascript"></script> <script> $(function(){ $(":input").focus(function(){ $(this).addClass("focus"); if($(this).val() ==this.defaultValue){ $(this).val(""); } }).blur(function(){ $(this).removeClass("focus"); if ($(this).val() == '') { $(this).val(this.defaultValue); } }); }) </script>
<script src="jquery-1.9.1.js" type="text/javascript"> //这个是引用jquery <script type="text/javascript"> //这个是脚本的开始标签,你没有写,加上去就好了
script标签,src引用和代码实体部分应该分开写,有src引用的部分内容一定要留空。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
应该是两个script标签吧
script标签,src引用和代码实体部分应该分开写,有src引用的部分内容一定要留空。