jQuery 组合框附加一个模糊事件

jQuery combobox attach an on blur event

我指的是以下内容 url http://jqueryui.com/autocomplete/#combobox 在我的 HTML 页面中呈现组合框。 我想将模糊事件附加到我的组合框,以便当用户单击组合框然后移动到下一个字段时,我可以触发验证消息。 在搜索时,我发现只有一个 select 事件可以附加,当您 select 来自组合框的值时会触发该事件。

HTML 代码

  @Html.DropDownListFor(m => m.Reason, new SelectList(ViewBag.SelectReason, "Key", "Value"), "", new { id = "drop2", placeholder = "Select Reason" })

Jquery代码:

  $("#drop2").blur(function () {
           // here goes your code
        alert("blur");
    });

有什么方法可以触发 onBlur 事件吗?

您的页面中应该仍然有这样的内容才能启用 combobox<select id="combobox">

然后,您可以直接使用jquery在select元素上应用blur事件:

$("#combobox").blur(function(){
    // here goes your code
}

我终于设法使用这个

将模糊事件附加到我的组合框
     $('#myDropDownName').next().find('input').blur(function () {

      //My Action
    });