0

Using jQuery I need to remove this html code and the {menu} tag inside when the browser or window is resized to a smaller screen size for responsive web design.

<div id="menu">{menu}</div>

I'm new to jQuery so any help or advice will be greatly appreciated.

1
  • Does that mean that #menu should come back if the screen gets large enough again? Commented Jan 26, 2013 at 20:52

1 Answer 1

2

You don't necessarily need to use jQuery, just add a media query to your style sheet:

@media screen and (max-width:480px)
{
    #menu { display: none; }
}

This way, if the screen happens to change (e.g. goes to landscape, or perhaps the browser is resized), the menu will re-appear again.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 this is very smooth. Nice one, I just played around with it in a basic fiddle and the results are nice. I don't even feel like my jQuery alternative answer is relevant and I remove it for now, unless OP can't amend CSS or has any other reservations/issues with the CSS solution.
Man I was just about to implement JQuery when I saw this thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.