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 01-09-2012, 11:30 PM   PM User | #1
lilmousiee
New Coder

 
Join Date: Nov 2011
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
lilmousiee is an unknown quantity at this point
$(this).attr() trouble

Code:
$(document).ready(function() {
	$(".alert").click(function() {
		{
			var id = $(this).attr("id");
			alert(id);
			$(id).dialog();
			return false;
		}
	});
});
Ok it's alerting the id AFTER it alerts an undefined.. so it alerts "undefined" and then "5" or whatever the number may be.
What am I doing wrong?
lilmousiee is offline   Reply With Quote
Old 01-10-2012, 02:12 AM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
How many elements with class “alert” do you have in your document? Maybe the first match doesn’t have an ID?

Also, IDs must not start with a number, only with letters A–Z or a–z.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 01-10-2012, 09:37 AM   PM User | #3
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
If your id=="5" (which is not a proper id), what the heck do you expect
Code:
$(id).dialog()
to do?
devnull69 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 08:30 AM.


Advertisement
Log in to turn off these ads.