Input slideUp/slideDown issue

前端 未结 2 1770
半阙折子戏
半阙折子戏 2021-01-24 13:42

Seems like jQuery removes the value of a input fields that has been slided up and then afterwards down. Not quite sure if it\'s the placeholder who does it but the built in slid

2条回答
  •  故里飘歌
    2021-01-24 14:25

    Error occurs when height of the input comes 0. You should change your method. Use css position with masking animate method:

    Here is demo link. You'll inspect there will be no bug with this method.

    jQuery:

    $(document).ready(function () {
        $('#slideUp').click(function () {
            $('input[type="text"]').stop().animate({'top':'200px'},400);
        });
    
        $('#slideDown').click(function () {
            $('input[type="text"]').stop().animate({'top':'0px'},400);
        });
    });​
    

    html:

    css:

    #mask { position:relative; 160px; height:25px; overflow:hidden; top:0; left:0; }
    #motion { position:absolute; top:0; left:0; }
    input { position:relative; } ​
    

提交回复
热议问题