zoukankan      html  css  js  c++  java
  • 用val()获取与设置input的值

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     5 <title>无标题文档</title>
     6 <style type="text/css">
     7 input{ color:#CCC;}
     8 .class01{ color:#000;}
     9 </style>
    10 <script type="text/javascript" src="jquery-1.11.2.min.js"></script>
    11 <script type="text/javascript">
    12 $(function(){
    13     $('input').focus(function(e) {
    14         if($(this).val()=='请输入搜索内容')
    15             $(this).val('').addClass('class01');
    16     });
    17     $('input').blur(function(e) {
    18         if($(this).val()==''){
    19             $(this).val('请输入搜索内容').removeClass();    
    20         }
    21     });
    22 })
    23 </script>
    24 </head>
    25 
    26 <body>
    27 <input type="text" value="请输入搜索内容">
    28 </body>
    29 </html>
  • 相关阅读:
    IO流
    异常,File,递归,IO流
    Collection接口 map
    使用canvas画出的时钟
    js对象2
    js对象
    js 猜数游戏、斗地主发牌、伪数字
    js函数2
    js函数
    js矩形,数组,杨辉三角
  • 原文地址:https://www.cnblogs.com/darkterror/p/5007447.html
Copyright © 2011-2022 走看看