码迷,mamicode.com
首页 > 其他好文 > 详细

字段的占位符文本

时间:2014-07-03 20:17:52      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:style   blog   java   color   width   os   

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>搜索框占位符文本</title>
    <style type="text/css">
*{font-size:12px;}
#switcher input{height:26px;width:200px;}
.overlabel{position:raletive;}
.overlabel label{position:absolute;top:16px;left:16px;}
    
    </style>
    <script src="./jquery.js"></script>
<script type="text/javascript">


$(function(){
    var $search=$("#search").addClass("overlabel");//虽然是给变量赋值,但是已经执行了,同时,其实执行完毕还是它本身
    var $searchInput=$search.find("input");
    var $searchLabel=$search.find("label");
    if($searchInput.val()){
        $searchLabel.hide();
    }
    $searchInput.focus(function(){
        $searchLabel.hide();
    })
    .blur(function(){
        if($searchInput.val()==‘‘){
        $searchLabel.show();
        }
    });
    $searchLabel.click(function(){
        $searchInput.trigger("focus");
    });
});

</script>
  </head>
  
  <body>
<div id="switcher">
<form id="search" method="" action="" >
<label>字段的占位符文本</label>
<input type="text" value="" id="txt" maxlength="150" name="txtname" />
</div>
</body>
</html>

 

字段的占位符文本,布布扣,bubuko.com

字段的占位符文本

标签:style   blog   java   color   width   os   

原文地址:http://www.cnblogs.com/cblx/p/3821194.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!