Results 1 to 4 of 4

Thread: Removing Option Groups

  1. #1
    Join Date
    Jun 2014
    Location
    Charlottesville
    Posts
    11
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Removing Option Groups

    Can anyone please explain why jQuery works on the original code but deletes all the option for my code.

    Original Code:
    http://jsfiddle.net/frJEq/

    My Code:
    http://jsfiddle.net/frJEq/43/

    I have multiple of the exact same select menu so that's why I have it setup for the concat to put in the counter. But why does it work for the original and not mine??? I have been pouring over code and examples and can't see why.

    Thomas

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    In your example, the option elements are actually inside of the optgroup. They aren't in the first example. Take a look at http://jsfiddle.net/frJEq/47/ for comparison.

    If you plan to wrap the elements inside the option group, you might find the unwrap() function more convenient: http://jsfiddle.net/frJEq/48/
    Last edited by Nile; 07-12-2014 at 03:56 AM.
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    javacrypter (07-12-2014)

  4. #3
    Join Date
    Jun 2014
    Location
    Charlottesville
    Posts
    11
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thank you so much Jeremy. I had tried to experiment with the unwrap() function, but I didn't think about doing the each part so I was just unwrapping the whole thing to just the text nodes of the options. By any chance is there a way to do this with just pure JS? I can load in the jQuery library, but as of now, I have written my entire program in pure JS and think it is a little silly to just call one function. I am pulling in a few different libraries, so it's no biggie, but also curious. Thanks in advance.

    Thomas

  5. #4
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Sure. Take a look at the below question.

    http://stackoverflow.com/questions/1...raw-javascript

    You'd just have to do a loop and everything would work out.
    Jeremy | jfein.net

Similar Threads

  1. Add/Remove Groups
    By Burgin in forum Looking for such a script or service
    Replies: 0
    Last Post: 04-29-2010, 01:15 PM
  2. Multi-cast groups
    By fred2028 in forum Other
    Replies: 0
    Last Post: 09-10-2009, 07:38 PM
  3. Join My Social Groups!
    By fileserverdirect in forum The lounge
    Replies: 1
    Last Post: 07-02-2008, 11:31 PM
  4. [DHTML] Collapsable Div with limit and groups
    By Master_script_maker in forum Submit a DHTML or CSS code
    Replies: 1
    Last Post: 12-26-2007, 11:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •