JQuery在所选事件上自动完成文本框

时间:2021-11-12 03:18:07

How do I fire another event after I have completed the selection on the textbox that has autocomplete. I want to show a valid div area based on the selected value.

完成对具有自动完成功能的文本框的选择后,如何触发另一个事件。我想根据所选值显示一个有效的div区域。

2 个解决方案

#1


Assuming you're talking about jQuery UI autocomplete, then like this:

假设您正在谈论jQuery UI自动完成,那么像这样:

$('#autocomplete').result(function(event, data, formatted) {
     alert('Someone picked a suggestion from the drop-down');
});

That is to say, the "result" method fires.

也就是说,“结果”方法会触发。

See http://docs.jquery.com/UI/Autocomplete/autocomplete#options

#2


function change() {

    document.getElementById('<%=btnLoadBenefits.ClientID %>').click();
}

<asp:Button ID="btnLoadBenefits" runat="server" OnClick="btnLoadBenefits_Click" style="display:none;"/>    

<asp:TextBox ID="txtCompanyname" runat="server" Width="220px" Height="18px"                                                                                                MaxLength="50" onchange="change();">
</asp:TextBox>

#1


Assuming you're talking about jQuery UI autocomplete, then like this:

假设您正在谈论jQuery UI自动完成,那么像这样:

$('#autocomplete').result(function(event, data, formatted) {
     alert('Someone picked a suggestion from the drop-down');
});

That is to say, the "result" method fires.

也就是说,“结果”方法会触发。

See http://docs.jquery.com/UI/Autocomplete/autocomplete#options

#2


function change() {

    document.getElementById('<%=btnLoadBenefits.ClientID %>').click();
}

<asp:Button ID="btnLoadBenefits" runat="server" OnClick="btnLoadBenefits_Click" style="display:none;"/>    

<asp:TextBox ID="txtCompanyname" runat="server" Width="220px" Height="18px"                                                                                                MaxLength="50" onchange="change();">
</asp:TextBox>