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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:09:56+00:00 2026-06-02T20:09:56+00:00

Hy, i have a form in witch i have some select boxes, i use

  • 0

Hy, i have a form in witch i have some select boxes, i use a small and easy little jquery plugin to help me style them.

$.fn.extend({
customSelect : function(options) {

  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
  return this.each(function() {

        var outerClass = options.customClass,
            innerClass = options.customClass_inner;

        var currentSelected = $(this).find(':selected');
        var html = currentSelected.html();
        if(!html){ html=' '; }
        $(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+html+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
        var selectBoxSpan = $(this).next();
        var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));         
        var selectBoxSpanInner = selectBoxSpan.find(':first-child');
        selectBoxSpan.css({display:'inline-block'});
        selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
        var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
        $(this).height(selectBoxHeight).change(function(){
        selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
        }); 
  });
  }
}
});
$('select').customSelect();

And it’s ok, it works great, the problem is that i also have a button which if you click on ads more and more select boxes, as many as you want.(Never mind why :P)
These select boxes are created also with the help of jquery so i’m adding it dynamically to the dom.

So my problem is that these new select boxes of course don’t inherit the style, i know that it’s because i add them later to the dom, but who can i make them inherit with the help of the on method?

Thank you, for any help!

  • 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-02T20:10:00+00:00Added an answer on June 2, 2026 at 8:10 pm

    You just need to call again

    $('select.newSelect').customSelect();
    

    after you add the new select to the DOM. Be careful to add a peculiar class so that your customSelect() code applies only to newly added elements, otherwise you attach events twice. Ore you could generalize the plugin so that it doesn’t attach events twice but that’s more difficult (hint use .data() )

    To avoid doing strange things if you call $('select.newSelect').customSelect(); you could do

      if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
      return this.each(function() {
    
      if($(this).data('customSelectApplied') !== ''){
            // whe already attached the custom functionality here
            return;
        }else{
            //continue as usual
            $(this).data('customSelectApplied', true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with some input and select boxes, each has class=myClass .
Hi Guys i need some help with Jquery Validadion Plugin I have an input
I have a form with some select elements. One of them is configured so
Using ASP.NET VB, I have a form with some text boxes and a Gridview.
I have a form with multiple dropdownlists on it. Some of them possess multiple
I have a form with a table that has two input boxes, a select
I want to submit a form, follow link, select some check boxes & Radio
I have a source file with a select form with some options, like this:
I have a form with some fields like text , select etc. I need
I apologize in advance, I am a PHP noob! I have form with some

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.