Javascript在Chrome中工作,但在IE或Firefox中不起作用
Javascript works in Chrome, but not in IE or Firefox
选中一个或多个复选框并单击"比较游览"按钮时,应会出现一个弹出窗口。但是,此功能仅在 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" />
你的函数应该接受一个名为"event"的参数,不是吗? 它没有的事实当然是它在Firefox中不起作用的原因。
你缺少一个 });在最后。您需要关闭 $(文档).ready
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- IE/Chrome中未定义的函数,但Firefox中没有
- 滚动在Chrome中有效,但在Firefox或IE中无效
- document.images未加载在chrome或firefox上,但已加载在IE上
- 为什么这个按钮在IE中有效,但在Firefox中无效
- 无法在IE、Firefox中使用adobeacrobat9pro调试PDF中的javascript
- 以下颜色更改功能在IE9和Firefox中运行良好,但在早期的IE或Chrome中则不然
- 通过单击主菜单外部关闭子菜单'不适用于IE,但适用于Firefox&铬
- jquery表单提交无法使用多个输入(IE和Firefox)
- Multi-platform (Chrome, IE, Firefox)
- contentEditable and lastChild IE, Firefox & Chrome LastC
- onblur事件在IE/Firefox/Chrome中有所区别
- Javascript代码关闭标签,适用于IE, Firefox和Chrome
- window.print()对话框在IE, Firefox和Safari中正常工作时,在Chrome中不显示
- IE/Firefox气泡事件
- MarginLeft不工作在IE/Firefox内的功能(但从控制台工作)
- 在IE/FireFox/Chrome中横向打印DIV
- 通过javascript的IE/Firefox样式更新不工作
- 在Chrome / Safari下载文件期间$ajax调用挂起,而不是在IE / Firefox中
- 如何在IE, Firefox和Chrome中使用谷歌网页字体