Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2012, 02:35 PM   PM User | #1
m2244
Regular Coder

 
Join Date: Jun 2012
Posts: 129
Thanks: 1
Thanked 1 Time in 1 Post
m2244 is an unknown quantity at this point
Why is this simple click not working

Hello,

I have tried click, live, bind. If I just put an alert in the ready function, I get the alert. Nothing seems to work for the click function.

Code:
$(document).ready(function(){
			$("#prevButton").click("click",function(){alert("You clicked the previous button.");});
			
			
	});
Code:
<input id="prevButton "type="button">Previous</input>
	<input id="nextButton "type="button">Next</input>
m2244 is offline   Reply With Quote
Old 12-04-2012, 03:13 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Why would you want to specify "click" as the first parameter to the .click() event handler? Just remove it ... you would only need it for .bind(), .live() or .on()
devnull69 is offline   Reply With Quote
Old 12-04-2012, 04:33 PM   PM User | #3
m2244
Regular Coder

 
Join Date: Jun 2012
Posts: 129
Thanks: 1
Thanked 1 Time in 1 Post
m2244 is an unknown quantity at this point
Quote:
Originally Posted by devnull69 View Post
Why would you want to specify "click" as the first parameter to the .click() event handler? Just remove it ... you would only need it for .bind(), .live() or .on()
Dang it. It was not in there when I tried the click earlier, then I tried live, on ,etc. It still does not work.
m2244 is offline   Reply With Quote
Old 12-04-2012, 04:54 PM   PM User | #4
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
he means do it like this

Code:
$(document).ready(function(){
			$("#prevButton").click(function(){alert("You clicked the previous button.");});
			
			
	});
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 12-04-2012, 07:24 PM   PM User | #5
m2244
Regular Coder

 
Join Date: Jun 2012
Posts: 129
Thanks: 1
Thanked 1 Time in 1 Post
m2244 is an unknown quantity at this point
Quote:
Originally Posted by DanInMa View Post
he means do it like this

Code:
$(document).ready(function(){
			$("#prevButton").click(function(){alert("You clicked the previous button.");});
			
			
	});
That's what I had when I started. Not working for me. No errors. No idea.
m2244 is offline   Reply With Quote
Old 12-04-2012, 08:28 PM   PM User | #6
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
Quote:
Originally Posted by m2244 View Post
That's what I had when I started. Not working for me. No errors. No idea.
then something else is wrong. i take it this isnt the only code on the page?
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 12-04-2012, 08:29 PM   PM User | #7
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
You need to remove the space(s) in the ids:

Code:
<input id="prevButton "type="button">Previous</input>
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:44 AM.


Advertisement
Log in to turn off these ads.