Reputation: 7517
my code:
$(document).ready(function(){
alert("document ready");
$("input[type=radio]").click(function(event){
alert("clicked");
});
});
But no alert shows up... And, when typing in on the console:
$(document).ready(function(){ alert("document ready");})
I get the alert! What is going on here?
Upvotes: 4
Views: 11206
Reputation: 7517
I found the solution, it explains as well why it does work in JSFiddle.
The problem was how I imported jQuery: I did
<script type="text/javascript" src="jQuerylink" />
and it had to be
<script type="text/javascript" src="jQuerylink" ></script>
I don't know why this is so, but now it works. Thanks for all effort.
Upvotes: 2
Reputation: 218862
$(function(){
$("input[type='radio']").click(function(){
alert("clicked");
});
});
Example http://jsfiddle.net/Dw6Fp/2/
Upvotes: 1
Reputation: 20201
According to the jQuery selector docs [link] you should enclose parameter value with double quotes:
$('input[type="radio"]').click(function(event){
OR
$("input[type=\"radio\"]").click(function(event){
UPDATE: JSFiddle example
Upvotes: 0