[英]Javascript onclick function on div works only in IE
I have this code to call a function on a div when it's clicked: 我有这个代码在单击时调用div上的函数:
<div class="buttonsim" runat="server">
$(document).ready(function () {
$("div.buttonsim").click(function() {
window.location.href("sim.aspx");
});
});
It works on IE but not on Chrome and Firefox> Am I doing something wrong? 它适用于IE但不适用于Chrome和Firefox>我做错了吗? Is it missing something?
它丢失了什么吗?
You need to actually set the window.location.href
property as you are currently using it as a method : 您需要实际设置
window.location.href
属性,因为您当前正在将其用作方法:
$("div.buttonsim").click(function() {
window.location.href = "sim.aspx";
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.