This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JQuery replace div Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JQuery replace div" Watch "JQuery replace div" New topic

JQuery replace div

Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
I have a div element1

and inside I have a menu div and a content div, like this:

But I do also have another menu2 which is hidden and will be display when user select one of the menu item in "id=menu" Menu. In css, i put like this:

I want to replace id=menu with id=menu2 when user click item in id=menu, my jquery would be :

Surprisingly, the first time user click item in id=menu the id=menu2 appears and replaced id=menu.
But then try again 2nd time, it doesn't work. The id=menu2 is not appearing. Unless I refresh my page.

Am I doing anything wrong with my JQuery code ?

Please help...its urgent

From NickyEng
Diploma in Computer Studies
SCJP 1.4
Formula 1 app by Maxis (Playbook)
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
That html markup is invalid, you are missing uls.

You are creating two copioes of the same element on the page. You need to remove the original one.

Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
I used .hide() and .show()...and it works.

Thanks a lot then.
It is sorta covered in the JavaRanch Style Guide.
subject: JQuery replace div
Similar Threads
jQuery AJAX display issue
Problem with YUI tabs while populating pdf's
Spring display tab menu
Not achieving space between div blocks containing lists
Regarding Menu with sub menus