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 06-17-2009, 08:03 PM   PM User | #1
lauthiamkok
Regular Coder

 
Join Date: Dec 2008
Posts: 117
Thanks: 14
Thanked 0 Times in 0 Posts
lauthiamkok is an unknown quantity at this point
jQuery: addClass at onclick

Hi,
I would like to add a class to the <li> or <a> tag when a particular link is clicked. This is the html,

Code:
<ul>
            <li><a href="#" onclick="loadPage('1.php'); return false;">1</a></li>
            <li><a href="#">2</a></li>
            <li><a href="#">3</a></li>
</ul>
jquey's ajax,

Code:
function loadPage(parameter) {
this.addClass('current');
$("#content").html('<div id="ajaxloader"><p><img src="img_iconies/loader_0.gif"/> loading...</p></div>');
$("#content").load( "incl_contents/" + parameter, {}, function(){ //calling the ajax then with a callback afterwards
 	$("#content").css({display:'none'})
	.fadeIn("slow");
 	});
}
it works fine until i put this line in,

Code:
this.addClass('current');
I think it is probably it is incorrect the way i try to add the class to the link.

Many thanks if u have any ideas.

Lau
lauthiamkok is offline   Reply With Quote
Old 06-17-2009, 11:16 PM   PM User | #2
digital-ether
New Coder

 
Join Date: May 2006
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
digital-ether is an unknown quantity at this point
Have you tested it?

That should work, and add the class to the anchor.
__________________
Fiji Web Design - where i do Joomla Web Design
Bucabay.com - My blog
digital-ether is offline   Reply With Quote
Old 06-18-2009, 12:51 AM   PM User | #3
lauthiamkok
Regular Coder

 
Join Date: Dec 2008
Posts: 117
Thanks: 14
Thanked 0 Times in 0 Posts
lauthiamkok is an unknown quantity at this point
Quote:
Originally Posted by digital-ether View Post
Have you tested it?

That should work, and add the class to the anchor.
yes i did but it didnt work... i have tried this but it doesnt work too,

Code:
$(this).addClass("current");
lauthiamkok 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 11:38 AM.


Advertisement
Log in to turn off these ads.