0

I'm a jQuery newbie and I've spent hours trying to find the answer to this and the documentations didn't help me much.

I simply want to change the style of:

#footer_menu{bottom:0;}

to

#footer_menu{bottom:-48px;}

once ANY link on the page is clicked. No IDs whatsoever, I just want to be able to trigger that function whenever ANY link is clicked.

I'm starting to wonder this is not at all possible and it should be done by adding IDs to the A tags. is this true and what's the best way to achieve this?

3 Answers 3

4

Try like this, Demo on JsFiddle

$('a').click(function() {      
   $('#footer_menu').css('bottom', '-48px');
});
Sign up to request clarification or add additional context in comments.

Comments

3
$('a').on('click', function(e) {
     $('#footer_menu').css('bottom', '-48px');
     e.preventDefault();
}

Comments

2
$('a').on('click', function(event) {
    $('#footer_menu').css('bottom', '-48px');
    event.preventDefault(); // only if links should not navigate afterwards
});

You just basically select all anchors with $('a').

1 Comment

I ended up doing something else to fix what I wanted, but this helped eliminate the fact that I thought this method was going to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.