简体   繁体   English

模糊事件会在移动设备上使用jQuery取消Click事件

[英]Blur event cancels Click events with jQuery on Mobile device

I have a blur event in a textarea: 我在文本区域中发生了模糊事件:

$("#question-id-5-answer").blur(function (event) {}

And a click event in the Submit button: 在“提交”按钮中单击事件:

$("#" + _sendBtnId).on("click", function () {} 

It happens that the Click event does not fire because the Blur event cancel the click event. 发生Click事件不会触发是因为Blur事件取消了click事件。

I can't use the Mousedown event because it's a touch device that does not detect it. 我无法使用Mousedown事件,因为它是无法检测到的触摸设备。

I tried saving the following on my mobile device as a htm file and accessed using Forefox application. 我尝试将以下内容保存为htm文件在移动设备上,并使用Forefox应用程序进行访问。 Appears to be working as expected. 似乎正在按预期方式工作。 Please have a look if it helps you. 请查看它是否对您有帮助。

<form id="myForm">
    <textarea id="myTxt"></textarea>
    <input type="button" id="butSubmit" value="Submit" />
</form>

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>

$(document).ready(function() {

    $("#myTxt").blur(function() {
        if($(this).val() != "") {
            alert("retunging false");
            return false;   
        }

        alert("rextarea is empty");
    });

    $("#butSubmit").click(function() {
        alert("submitted");
    });

});

</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM