NULL
NULL

Reputation: 1589

jquery not working in IE, Chrome, works in FF

I made a last minute change to my code and realized the jQuery is not working in IE and Chrome, but in FF runs fine. I managed to change some of the existing jQuery to js, and it works fine in all browsers, however, the below jQuery fails to work in IE and Chrome.

I am hoping I don't need to change this code to pure JS, so hopefully there is a work around, any ideas what I am doing wrong?

<!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>

Upvotes: 1

Views: 307

Answers (2)

flavian
flavian

Reputation: 28511

Most browsers rely on type, not language to trigger the JavaScript interpreter. So if you put <script type="text/javascript"></script>, you don't even need to specify language. The language attribute has been deprecated for a while now.

See this question.

Put this instead of what you currently have:

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

Also, for the HTTPS issue, use the following:

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

Or you can specify HTTPS directly:

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

Upvotes: 1

Pranav Singh
Pranav Singh

Reputation: 20111

I am repeating what J. Ghyllebert said before, is your website using https??

Please try downloading latest js file & save to local & reference it from local address within your website.

Upvotes: 0

Related Questions