jQuery focusin and focusout live events are not firing

后端 未结 3 1024
轮回少年
轮回少年 2021-01-18 08:25

jQuery Version: 1.4.1

I am attempting to write a simple watermark type plugin and I want to take advantage of live events since not all of the eleme

3条回答
  •  野的像风
    2021-01-18 08:39

    Try:

    $(document).ready(function(){
      $('input[type=search]').bind('focusin', function(){
        $(this).animate({width: '300px'}, 500);
        $('svg.magnifier').hide();
        $('svg.cancel').show();
      }).bind('focusout', function(){
        $('svg.cancel').hide();
        $('svg.magnifier').show();
        $(this).animate({width: '100px'}, 500);
      });
    });
    div.box_block {
      position: relative;
    }
    input[type=search] {
      width: 100px;
      padding: 10px 10px 10px 30px;
    }
    /* --
      SVG - https://www.iconfinder.com/iconsets/ionicons
    ----- */
    svg {
      position: absolute!important;
      left: 10px;
      transform: translateY(55%);
      top: 0;
    }
    svg.cancel {
      display: none;
    }
    
    

提交回复
热议问题