Input slideUp/slideDown issue

前端 未结 2 1757
半阙折子戏
半阙折子戏 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:23

    It seems like a bug in chrome (not jQuery). It works fine in ff.

    Its something related with font-size , I guess. Chrome does not loses font-size but if you set again, it works.

    $(document).ready(function () {
        $('#slideUp').click(function () {
            $('input[type="text"]').slideUp(1000);
        });
    
        $('#slideDown').click(function () {
            $('input[type="text"]').slideDown(1000,function(){ 
                 $(this).css('font-size',$(this).css('font-size'));                
            });
        });
    });​
    

    Demo

    EDIT:

    I see that above hack works for one time only. If you slide up/down again, it fails.

    Here's a better hack.

    .text{ 
        font-size:13px; 
    }​
    
    $(document).ready(function () {
        $('#slideUp').click(function () {
            $('input[type="text"]').slideUp(1000,function(){
                   $(this).removeClass('text');        
            });
        });
    
        $('#slideDown').click(function () {
            $('input[type="text"]').slideDown(1000,function(){    
                $(this).addClass('text');     
            });
        });
    });​
    

    Demo

提交回复
热议问题