LuigiEdlCarno
LuigiEdlCarno

Reputation: 2415

Simple jQuery function not called

There is an old web project I have to add some functionality to, and alot was done using plain javascript.

Because I wanted to start using jQuery, I wrote the following simple test:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="ISO-8859-1">
        <title>Radiotest</title>
        <script src="ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
        <script type="text/javascript">
$(document).ready(function(){
    $('#myButton').on('click', function() {
        alert("Test");
        alert($('input[name=Test]:checked', '#myForm').val()); 
    });
});
        </script>
    </head>
    <body>
    <div id="result"></div><br/>
    <form id="myForm">
        <input type="radio" name="Test" value="1"> 1<br>
        <input type="radio" name="Test" value="2"> 2<br>
        <input type="radio" name="Test" value="3"> 3<br>
        <input type="button" id="myButton" value="Check">
    </form>
    </body>
</html>

Unfortunately, when clicking on the button after selecting a radio element the function is not being called, or atleast none of the alerts get displayed.

Can you please help me spot the error. Thank you.

Upvotes: 0

Views: 67

Answers (3)

Murali Murugesan
Murali Murugesan

Reputation: 22619

In this case src="http://resource"

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

Upvotes: 1

Vicky Gonsalves
Vicky Gonsalves

Reputation: 11707

try this:

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

Upvotes: 2

Mooseman
Mooseman

Reputation: 18891

Your src attribute value ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js is invalid. You must either include the http:// or // to pickup the currently used protocol:

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

Upvotes: 3

Related Questions