Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuery replace div

 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Eric
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used .hide() and .show()...and it works.

Thanks a lot then.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic