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 7789347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:16:17+00:00 2026-06-01T21:16:17+00:00

http://jsfiddle.net/xuAQv/ <– Link to my bad code on JsFiddle. So i found this bit

  • 0

http://jsfiddle.net/xuAQv/ <– Link to my bad code on JsFiddle.

So i found this bit of code which coverts traditional form select boxes into their twitter bootstrap styled versions. It essentially just hides the select, and creates the html for a select box using bootstrap’s css / js.

http://blog.iamjamoy.com/convert-select-boxes-to-a-fancy-html-dropdown
I customized the plugin a bit to change the appearance of the drop downs.

The problem i have now is that the $(“#mySelect”).change(function(){}); no longer fires.
I tried adding .live to it, and .on to it, without any luck.

Do i need to modify the plugin?
Here is my code for the plugin..

/*!
 * Convert <select> elements to Dropdown Group
 *
 * Author: John Rocela 2012 <me@iamjamoy.com>
 * Customized: Frank B 3/2012
 */
jQuery(function ($) {
    $('select').each(function (i, e) {
        if (!($(e).data('convert') == 'no')) {
            //get some initial data...
            xSelect = $(e).attr('id')
            xLabel = $("#" + xSelect + " option:selected").text();
            xClass = $(e).data('class')
            $(e).hide().wrap('<div class="btn-group" id="select-group-' + i + '" />');
            var select = $('#select-group-' + i);
            select.html('<a class="btn dropdown-toggle ' + xClass + '" data-toggle="dropdown" href="javascript:;">' + xLabel + ' <span class="caret"></span></a><ul class="dropdown-menu"></ul><input type="hidden" value="' + $(e).val() + '" name="' + $(e).attr('name') + '" id="' + $(e).attr('id') + '" class="' + $(e).attr('class') + '" />');
            $(e).find('option').each(function (o, q) {
                select.find('.dropdown-menu').append('<li><a href="javascript:;" data-title="' + $(q).text() + '" data-value="' + $(q).attr('value') + '">' + $(q).text() + '</a></li>');
                if ($(q).attr('selected')) select.find('.dropdown-menu li:eq(' + o + ')').click();
            });
            select.find('.dropdown-menu a').click(function () {
                select.find('input[type=hidden]').live().val($(this).data('value')).change();
                select.find('.btn:eq(0)').html($(this).text() + ' <span class="caret"></span>');
            });
        }
    });
});
  • 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-06-01T21:16:19+00:00Added an answer on June 1, 2026 at 9:16 pm

    If you have a look at what is actually happening in the code, the select is being replaced by a hidden input. When you change the value, that is what is getting change() called on it. You will need to use event delegation. Something like this:

    $("<parent selector>").on("change","#mySelect", function(){}); 
    

    Where <parent selector> is a selector matching some parent of the select which is not replaced. If needed it can be the document but ideally you want it to be as far down the tree as possible.


    The reason your live didn’t work is because it should have been like this:

    $("#mySelect").live("change", function(){});
    

    Though you should not use live if you are using the latest jquery, you should use on.


    EDIT: Updated your fiddle: http://jsfiddle.net/xuAQv/2/

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

Sidebar

Related Questions

http://jsfiddle.net/ujTDf/1/ link text Can anybody help please. The div/form doesn't switsch automaticly in other
http://jsfiddle.net/FS4zT/ If you visit the above link you see what am describing below. Summary:
http://jsfiddle.net/rFEER/ <select id=users> <option value=1>jack</option> <option value=2>brill</option> <option value=3>antony</option> </select>​ js: $(#users).change(function(){ alert($(this).val()); })​
http://jsfiddle.net/YaMhn/8/ ^^^^Take a look and see if you can help solve this Ok so
http://jsfiddle.net/SXrAb/ Following the jsfiddle link there is a simplified sample of what I need.
http://jsfiddle.net/9BCrs/5/ I have this set up to load a file into a DIV using
http://jsfiddle.net/fJkBU/1/ That's my code. Basically, I have an iFrame whose source may change. I
http://jsfiddle.net/defencedog/2Skc7/ I am trying to remove the online class ONLY for administration which has
http://jsfiddle.net/zUAQC/11/ In this sample, In javascipt box's sampleDiv,I add the next input checkbox .
http://jsfiddle.net/2CkKW/5/ I'm trying to have a button for comments in which you will press

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.