为什么在我点击输入后立即在android chrome上运行模糊功能?

时间:2013-11-27 08:55:28

标签: android jquery html5 google-chrome

我有一个文本输入和标签,包含在div中。单击div换行时,会在子标签中添加一个类以使其淡化。在模糊时,类被删除。这在浏览器中工作正常,但在我的手机上,只要我点击输入,就会添加该类,然后立即删除。这是为什么?

我的jquery看起来像这样:

// listen for taps
$('.inputWrap').on('touchend',function(e){

    $(this).children('input,textarea').focus();
    $(this).children('label').addClass('ready');

});

// hide the label altogether once typing begins    
$('input,textarea').on('keypress',function(){

    $(this).prev('label').hide();

});

// on blur, check if the input is empty, if so, show the label again 
$('input,textarea').on('blur',function(){

    if($(this).val() == '')
    {
        $(this).prev('label').show().removeClass('ready');
    }

});

Here is a jsfiddle of it not working on mobile.如果您将“touchend”更改为单击,则可以在桌面和移动设备上运行,但这需要是一个触摸操作。

0 个答案:

没有答案