So,
I am currently removing and adding a class to an anchor with this:
$('#link a').removeClass('btn').addClass('scroll');
But I also need to remove the href in the '#link a' anchor tag too.
What's the cleanest/neatest way to acplish it all?
So,
I am currently removing and adding a class to an anchor with this:
$('#link a').removeClass('btn').addClass('scroll');
But I also need to remove the href in the '#link a' anchor tag too.
What's the cleanest/neatest way to acplish it all?
Share Improve this question asked Mar 13, 2015 at 2:18 causticcaustic 5852 gold badges8 silver badges18 bronze badges2 Answers
Reset to default 4You can use .removeAttr()
function
$('#link a').removeClass('btn').addClass('scroll').removeAttr('href');
Just going by your description I might try .toggleClass() just to be a bit cleaner.
$('#link a').toggleClass('btn scroll').removeAttr('href');