最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實(shí)現(xiàn)的placeholder效果完整實(shí)例

 更新時間:2016年08月02日 09:53:47   作者:Quber  
這篇文章主要介紹了jQuery實(shí)現(xiàn)的placeholder效果,可實(shí)現(xiàn)輸入框提示文字的功能,并且針對焦點(diǎn)的情況判定是否顯示,非常簡單實(shí)用,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)的placeholder效果。分享給大家供大家參考,具體如下:

運(yùn)行效果截圖如下:

具體代碼如下:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>jQuery實(shí)現(xiàn)placeholder效果</title>
  <script src="jquery-1.7.2.min.js"></script>
  <script>
    $(function () {
      initEvent();
    });
    //初始化提示內(nèi)容的顏色
    function initEvent() {
      $('input.holder').each(function () {
        var $this = $(this), holder = $this.data('holder');
        if (holder) {
          $this.css('color', '#a9a9a9').val(holder);
        }
      });
      //獲取焦點(diǎn)時設(shè)置內(nèi)容的顏色和值為空
      $(document).off('focus', 'input.holder').on('focus', 'input.holder', function () {
        var $this = $(this);
        if ($this.val() === $this.data('holder')) {
          $this.css('color', 'black').val('');
        }
      });
      //失去焦點(diǎn)后還原提示內(nèi)容
      $(document).off('focusout', 'input.holder').on('focusout', 'input.holder', function () {
        var $this = $(this);
        if ($.trim($this.val()) === '') {
          $this.css('color', '#a9a9a9').val($this.data('holder'));
        }
      });
    }
  </script>
</head>
<body>
  <input type="text" class="holder" name="name" value="" data-holder="請輸入賬戶" /><br><br>
  <input type="text" class="holder" name="name" value="" data-holder="請輸入密碼" />
</body>
</html>

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見經(jīng)典特效匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery form操作技巧匯總》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jquery中Ajax用法總結(jié)》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論

丘北县| 乌兰察布市| 亳州市| 长顺县| 治县。| 本溪| 七台河市| 哈巴河县| 淮北市| 柳州市| 四川省| 松潘县| 志丹县| 武乡县| 启东市| 镇宁| 安多县| 宜川县| 岳阳市| 平度市| 宁国市| 祁连县| 邛崃市| 涞水县| 香港| 榆树市| 阿坝| 阿拉尔市| 芮城县| 涟源市| 怀远县| 米泉市| 百色市| 米泉市| 双江| 松阳县| 铜梁县| 星座| 合肥市| 界首市| 长垣县|