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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:07:54+00:00 2026-06-14T19:07:54+00:00

Im writting a plugin to replace the original with another made by me with

  • 0

Im writting a plugin to replace the original with another made by me with html/css, in a few words, a selectbox.

I have problems of perfomance and I acknowledge my code it’s fairly heavy.
At first, I take the ID of each select and I add after an HTML code with some css params of the as width, position…

$(this).after("<div class="selectbox" s-id='"+$(this).attr("id")+"'> the code of the select </div>");

Then I hide the select, and here comes the part I think is quite heavy, I take all options of this and I do this

var selectbox=$("div[s-id="+selectID+"]"); //This is the div previously added after.

//each option of the select will be converted into a div
$.each($(this).find("option"), function(i) {
    var valor = $(this).val(),
        texto = $(this).text();

    if (i == 0) 
        selectbox.find(".class_valor").text(texto);//The first option to be shown

    //Then I add a li to my drop
    selectbox.find("ul").append('<li  data-value="'+valor+'">'+texto+'</li>');
});

And well, now, I don’t know if this is the best way to add events to the trigger that opens the dropdown and the click to an option, this is not inside the selectbox function, it’s outside inside the (function($){

Here is the code:
http://codepen.io/anon/pen/kcpxl

  • 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-14T19:07:55+00:00Added an answer on June 14, 2026 at 7:07 pm

    Small and easy improvements, cache $(this) and minimize DOM manipulation

    var selectbox=$("div[s-id="+selectID+"]"); //This is the div previously added after.
    
        //each option of the select will be converted into a div
        $.each($(this).find("option"), function(i) {
            var $this = $(this), 
                valor = $this.val(),
                texto = $this.text(), 
                liElems = '';
    
            if (i == 0) 
                selectbox.find(".class_valor").text(texto);//The first option to be shown
    
            //Then I add a li to my drop
            liElems += '<li  data-value="'+valor+'">'+texto+'</li>';
        });
    
        selectbox.find("ul").append(liElems);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writting a plugin and there is an option to write css from admin
I have a CSS file which contains several hundred 16x16 icons. They are referenced
I have tried and failed to create to find any good tutorials on writting
I am writting a plugin for a program, and I want to put my
I am writting a jquery plugin to create ajax calls designed for my app.
I have an enormous file of HTML that I'd like to convert to one
I'm looking for a jQuery plugin that either replaces or improves the HTML <select>
where do i start on writing plugin test? I have written some toy plugins
I am writing the plugin for jQuery. I have the problem with the extension
I writting a NPAPI plugin which contains two plugin types: x-capture used to capture

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.