首页 > 其他 > 详细

搜索框

时间:2016-07-11 00:50:55      阅读:222      评论:0      收藏:0      [点我收藏+]

搜索框实列

技术分享

技术分享
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
             .gg{
                  color:#dddddd;           (浅灰色)
            }
            .bb{
                  color:black;                  (黑色的字体)
             }
    </style>
</head>
<body>
         <input type="text" class="gg" value="请输入内容" onfocus="Focus(this);" onblur="Blur(this);"/>
<script>
     function Focus(ths){
            //查找第一种方式
            //document
            //第二种方式 (this)
            //ths
            ths.className = "bb";
            var current_val = ths.value;
            if(current_val == "请输入内容"){
                ths.value = ""
            }
      }
      function Blur(ths){
            var current_val = ths.value;
            if(current_val == "请输入内容" || current_val.trim().length == 0){
                   ths.value = "请输入内容";
                   ths.className == "gg";
             }
       }
</script>
</body>
View Code

 

搜索框

原文:http://www.cnblogs.com/wuyongcong/p/5658926.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!