Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  125] [ 6]  / answers: 1 / hits: 17343  / 15 Years ago, mon, may 25, 2009, 12:00:00

I have this method that changes an larger image source on click.



I need to add a 'current' class on the selected. I have no problem adding this class,but I need it to remove the class on the other, previous, selected item.



This is the code I'm using at the moment:



$(document).ready(function() {
$(ul.timgs li a).click(function(e) {
e.preventDefault();
var path = $(this).attr(href);
$(div.tour-image img).attr({src: path});
});
});


Thanks :-)


More From » jquery

 Answers
174

This should work:



$(ul.timgs li a).click(function(e) {
$(.current).removeClass(current);
$(this).addClass(current);
...
}

[#99463] Wednesday, May 20, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
miles

Total Points: 256
Total Questions: 111
Total Answers: 104

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
;