JQuery 1.8.3。选择器功能在IE中不工作
剧本 调试器行在IE中从未出现过,但在Chrome和Firefox中却出现过 .ASPXJQuery 1.8.3。选择器功能在IE中不工作,jquery,asp.net,ajax,Jquery,Asp.net,Ajax,剧本 调试器行在IE中从未出现过,但在Chrome和Firefox中却出现过 .ASPX 是否有已知的bug或其他什么?我似乎在网络上的任何地方都找不到答案。可以看出,选择器工作正常: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ListBox ID="ListBox1" runat="server" ClientIDMode="St
是否有已知的bug或其他什么?我似乎在网络上的任何地方都找不到答案。可以看出,选择器工作正常:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server" ClientIDMode="Static"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
相反,onclick不会为选项项触发。这可能是ie的一个限制。您可以向列表框添加onclick,但不能添加选项:
$('#ListBox1 option').first().css('background-color', 'red');
例如:
正如您所说,这在chrome中有效,但在ie中无效
更新:
如果要查找选定的项目,可以使用以下选项
$('#ListBox1').click(function () {
alert('listbox');
});
使用开发工具(F12)检查控件的实际ID。Web表单因更改元素id而臭名昭著。我将id设置为静态。检查ID,它是ListBox1。ClientIDMode=“static”也可以:您可以使用ListBoxClick事件并找出所选项目。这就像一个魅力男人。IE没有像其他浏览器那样玩得很好,这让我有点难过。
$('#ListBox1').click(function () {
alert('listbox');
});
$('#ListBox1').click(function () {
var selected = this.options[this.selectedIndex]
var text = 'value: ' + selected.value + ' text: '+ selected.label;
alert(text);
});