Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Unable to remove divs from main div jquery

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If a user selects a option then on change event will be invoked. Upon that event dynamically here I'm creating divs and will be added to main div (#radiobuttons id). If a user selects another option previous divs should be removed and new divs should be added to main div (#radiobuttons).

in html,


in js,




but here the problem is remove function is removing all the divs including newly added divs also.
 
author
Posts: 15385
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are removing the div. It is removing the whole element, it is NOT removing the content in the element. So when you add to it, there is no element there to add too!



If you want to remove the elements inside, you want to use empty()


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic