gpt4 book ai didi

Javascript 在 Chrome 中有效,但在 IE 或 Firefox 中无效

转载 作者:行者123 更新时间:2023-11-30 13:20:26 26 4
gpt4 key购买 nike

当选中一个或多个复选框并单击“比较游览”按钮时,应该会出现一个弹出窗口。但是,此功能仅适用于 Chrome。我该怎么做才能让它在 Firefox 和 IE 中运行?

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
<script type="text/javascript">
$(document).ready(function () {
var selectedCheckboxes = $("input:checkbox[id$=Select]");
$("[id*=CompareTop]").click(function() {
if (selectedCheckboxes.filter(":checked").length <= 1) {
event.preventDefault();
alert("Please select at least 2 tours to compare.");}
});
selectedCheckboxes.change(function() {
if (selectedCheckboxes.filter(":checked").length > 3){
$(this).removeAttr("checked");
alert("At most 3 tours may be compared.");
}
});
});

</script>
<sc:Placeholder ID="phHeader" Key="ph_header" runat="server" />

最佳答案

你的函数应该接受一个名为“事件”的参数,不是吗?事实上,它不能在 Firefox 中运行。

关于Javascript 在 Chrome 中有效,但在 IE 或 Firefox 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10386313/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com