Reputation: 1525
I am a newb to JQuery and am studying out of a book. For some crazy reason this selector /event sdtatement refuses to work even though according to the book it is supposed to work. I know that JQuery is loading as I can get an alert() to work. So can someone tell me what is wrong with this snippet ??
<script src="http://www.ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/global.js"></script>
$('input#name-submit').on('click',function(){
alert(1);
});
The console says that $ has not been defined. the php statement just refers to the base url in Codeigniter.
Many thanks
Upvotes: 0
Views: 58
Reputation: 131
Maybe you need to put the code like this:
<script>
$('input#name-submit').on('click',function(){
alert(1);
});
</script>
Between a script tag
Upvotes: 0
Reputation: 5050
beside what Guilherme mentioned You need to wrap your selector inside a tag
<script type="text/javascript">
$(function(){
$('input#name-submit').on('click',function(){
alert(1);
});
});
</script>
Upvotes: 0
Reputation: 14456
Think you just need to take the www
out of the URL for the jQuery src.
Upvotes: 2