I am new to Javascript, I am using Backbone So I add a style like this(to a link when its clicked)
$(eventC.target.parentNode).css('border', '1px solid red');
I want the previous link to be cleared of the red border I added when I click on new link
I looked at link below jQuery - remove style added with .css() function
So in essence I want to do this:
$(OLDLINK).css('border', 'none');
$(NewLINK).css('border', '1px solid red');
with events I get from backbone
Is there a simple way to do this? or is this approach just wrong?
I suggest using a CSS class for adding the border and to add / remove it like below
CSS:
.borderRed
{
border : 1px solid red;
}
jQuery:
//remove border from old link
$('.borderRed').removeClass('borderRed');
// add border in new link
$(eventC.target.parentNode).addClass('borderRed');