Hi guys, need a quick help here. I have a series of hyperlinks all with the same class name. I want that when I click on anyone of the links - the background colors of all the other hyperlinks change except the link I have clicked.
views:
488answers:
4
+6
A:
$('.className').click(function() {
$('.className').not(this).css('backgroundColor', '#ccff00');
});
Alexander Gyoshev
2009-09-02 07:06:58
+2
A:
Another option here.
Define a CSS class "visited". And then..
$('#sidebar a').visited().addClass('visited');
simplyharsh
2009-09-02 07:08:20
a really nice suggestion, yet he didn't ask for visited links...
Alexander Gyoshev
2009-09-02 07:15:48
He had got the answer earlier. Just thought to give a suggestion of an option.
simplyharsh
2009-09-02 07:26:52
A:
$("a").onclick(function () {
$(this).css("color");
});
With jQuery you can alter the CSS settings directly - so just build a function, choose a trigger (onclick, mouseover etc.) and you can alter the CSS settings...
Gnark
2009-09-02 07:08:52
+2
A:
I would create another class that has the new background color and apply it to all except the one that was just clicked.
$('.first_class').click(function(){
$('.first_class').not(this).addClass('new_class')
});
theIV
2009-09-02 07:09:00