jquery不工作在IE, Chrome,工作在FF

jquery not working in IE, Chrome, works in FF

本文关键字:工作 FF Chrome IE jquery      更新时间:2023-09-26

我做了最后一分钟改变我的代码,并意识到jQuery不能在IE和Chrome中工作,但在FF中运行良好。我设法将一些现有的jQuery更改为js,它在所有浏览器中都能正常工作,然而,下面的jQuery无法在IE和Chrome中工作。

我希望我不需要将此代码更改为纯JS,所以希望有一个工作周围,任何想法我做错了什么?

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#address').change(function() {
        $('#mycheckboxdiv').toggle();
    });
    $('#name').click(function() {
        alert("well hello there.");
    });
    $('#school').keyup(function(e) {
        if (e.which == 9)                                    
            alert("great school");
    });
});
</script>
</head>
<body>
<form name="myform" method="post" action="myform.php" id="myform">
<table>
<tr>
  <td><b>Name:</b></td>
  <td><input name="name" id="name" value="" type="text" size="20" maxlength="20"/></td>
</tr>
<tr>
<td valign="top">
<input name="address" value="NO" type="checkbox">  NO<br>
<input name="address" id="address" value="YES" type="checkbox">  YES</td>
</tr>
<tr id="mycheckboxdiv" style="display:none">
<td colspan="2"></td>
</tr>
</table>
</form>
</body>
</html>

大多数浏览器依赖type而不是language来触发JavaScript解释器。所以如果你用<script type="text/javascript"></script>,你甚至不需要指定languagelanguage属性已经被弃用一段时间了

参见这个问题。

用这个代替你现在的:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

同样,对于HTTPS问题,使用以下命令:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

或者直接指定HTTPS:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

我重复J. Ghyllebert之前说过的话,你的网站使用https吗??

请尝试下载最新的js文件&保存到本地&