Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6934727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:59:52+00:00 2026-05-27T11:59:52+00:00

I’m working on a select element replacement script for a kiosk project that takes

  • 0

I’m working on a select element replacement script for a kiosk project that takes a element and replaces it and it’s <options>s with divs. I have two versions – ‘normal’ and ‘modal’ for both <select> and <select[multiple="multiple"]> elements. Independently of each other, the individual replacements work as they should. When I place all of them on a page, they break functionally. In particular, for both the non-modal <select> and non-modal <select[multiple="multiple"]> aren’t toggling classes when their respective div.options are clicked. I believe there is some kind of conflict with the jQuery that’s causing the problem, but I’m too much of a novice to figure it out.

In my code, you’ll notice alot of variables and instances of adding html, which may seem unnecessary. The purpose of the script is to replace form elements being generated by a form builder which generates a simple tag and cannot be altered.

I’ve included my code here: http://jsfiddle.net/zumwalt/52At7/

Any help is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:59:54+00:00Added an answer on May 27, 2026 at 11:59 am

    Here is what is happening:

     $('div.select-normal div.option-'+value+'').click(function() { 
         option.prop("selected", "selected");
         $('div.select-normal div.option').removeClass('selected');
         $(this).toggleClass('selected');
     });
    

    When the code above executes for your normal select many, the css class is correctly being applied. However, later on you have this code for the modal select many:

    $('div.option').click(function() {
        var value = $(this).attr('id');
        var option = $('option[value=' + value + ']');
        var optiontext = $(this).text();
    
        option.prop("selected", !option.prop("selected"));
        $(this).toggleClass('selected'); // HERE IS THE ERROR
        if ($(this).hasClass('selected')) {
            $('ul.multiselect-dropdown-options')
                .append('<li id="' + value 
                    + '" class="dropdown-option drop-down-option-' 
                    + value + '">' + optiontext 
                    + '<a class="remove-option">x</a></li>');
        } else {
            $('.drop-down-option-' + value).fadeOut().remove();
        }
    });
    

    Since clicking on the normal select many also triggers a $(‘div.option’).click(), it is executing toggleClass and removing the ‘selected’ class that was added before.

    BTW, it is very hard to debug your fiddle if you are working on it. When posting a fiddle to SO, please post a fork URL that you will not be editing.

    Update

    Give a man a fish and he eats for a day… teach a man to fish and he eats for a lifetime. Despite the fact that your fiddle was changing, I debugged this using the Google Chrome Developer tools. Just go to your fiddle, right click, and choose Inspect Element. Click the Scripts tab, and choose the “show/” script from the dropdown. You can then click on the line numbers to set breakpoints in the javascript. Go back to Chrome, do something in the Result pane, and Chrome should hit a breakpoint. You can then step through the actions and see, line by line, how the DOM is affected by your script.

    You will need to set breakpoints inside of your each() and click() functions though, as Chrome doesn’t have very good Step Into functionality (it steps into the jquery source). Also, having a 2-monitor display helps a LOT here, so that you can step through the debugger on one monitor while viewing the fiddle DOM result in another monitor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.