Ok, so need a link changed via jquery. The code below works fine but it acts immediately. I need the link to become active only on the next click, not on the current click. Hope that makes sense?
Any help appreciated.
$("#m-menu").click(function(){
$("#menu").animate({right: 0}, 500, "easeInOutCirc");
$(this).text($(this).text() == 'HOME' ? 'HOME' : 'HOME');
$(this).attr('href', 'http://backtohomepage.com');
});
EDIT: Thanks for all the answers guys – its not quite as simple as an every-other-click solution and big apologies for not being clearer first time round. Here’s the source page (I’ve not applied the above .attr code to this in order to better illustrate my requirement): http://joinersart.co.uk/mtest
Basically when the user clicks either the left/right arrows to navigate the gallery, you’ll see the menu bar shrinks. In order to get it back, you click “MENU”. Once its back out again, the “MENU” text, changes to “HOME” and takes on a new function – link to the home page. Of course, if you click the left/right arrows again, it toggles back to “MENU” and changes its function back to expanding the menu bar. So basically this one link has two functions (either as a homepage link – “HOME”, or as a menu bar expander – “MENU”) depending on whether the menu bar is sticking out or tucked in.
When I try to apply the above .attr code, this is what happens – the user clicks the “MENU link and instead of the menu bar expanding, they are immediately taken to the home page. So it activates the link too soon .click function is executed. What I need it to do is to expand the menu bar and change the text from “MENU” to “HOME” first. Only THEN when the user clicks it, do they go to the home page.
1 Answer