繁体   English   中英

如何使除超链接/输入按钮以外的所有内容都触发Jquery模糊

[英]How to have Jquery blur trigger on everything except hyperlinks/input buttons

我在让jquery动作达到理想功能时遇到了一个小问题。 当前,在特定领域(称为“ person_email”)的模糊情况下,一切都可以正常工作。 问题是,如果最终用户这样做,并决定单击例如由模糊触发的jquery的页面其余部分上的超链接,则用户会短暂地看到它,然后继续到相应的链接。

理想情况下,这样做将使模糊仅在未单击超链接时才触发。

var $email = $("#person_email");
var $hint = $("#hint_edit");

$email.on('blur',function() {
  $hint.hide; // Hide the hint
  $(this).mailcheck({
    suggested: function(element, suggestion) {
        // First error - Fill in/show entire hint element
        var suggestion = "Did you mean: <span class='suggestion'>" +
                         "<span class='address'>" + "</span>" +
                         "<a href='#' class='domain'>" + suggestion.address +
                         "@" + suggestion.domain + "</a></span>?";

        $hint.html(suggestion).fadeIn(150);
    }
  });
});

 $hint.on('click', '.domain', function() {
  // On click, fill in the field with the suggestion and remove the hint
  $email.val($(".suggestion").text());
  $hint.fadeOut(200, function() {
    $(this).empty();
  });
  return false;
 });
})

我想你要下车

$("a").on("click",function() {
  $email.off();
});

暂无
暂无

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

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