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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:22:25+00:00 2026-05-27T22:22:25+00:00

I need to make crossbrowser styled tags in jQuery. So instead of making clean

  • 0

I need to make crossbrowser styled tags in jQuery. So instead of making clean html SELECT element tags, i use nested elements. There will be a lot of selectboxes available on page, so they should work correctly with each other.

Edit: Fade effects “fadeIn() / fadeOut()” should be used instead of “hide() / show()”

Introducing an example:

Instead of having classic clean html element of dropdown list:

<select>
  <option>Option 1</option>
  <option>Option 1</option>
  <option>Option 1</option>
</select>

I have nested elements so i can style them properly:

<div class="gui-selectbox">
  <a class="gui-selectbox-button">
    <span class="gui-btn-l"></span>
    <span class="gui-btn-c">Option 1</span>
    <span class="gui-btn-r"></span>
  </a>
  <div class="gui-selectbox-dialog">
    <ul>
      <li>Option 1</li>
      <li>Option 2</li>
      <li>Option 3</li>
    <ul>
  </div>
</div>

Here is the code: http://jsfiddle.net/aspirinemaga/XR4Y3/

It should work in that way:

  • When i click on any element, it should close all selectboxes
  • When i click on “.gui-selectbox-button”, it should show “.gui-selectbox-dialog” of its parent “.gui-selectbox”
  • If user clicks outside of “.gui-selectbox-button” and “.gui-selectbox-dialog”, it should close every opened selectboxes

UPDATED:

How can i tell to function to not close parent div if current target is its child ?

Here is an example: http://jsfiddle.net/aspirinemaga/ejyRR/5/. It’ a third element.

  • 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-27T22:22:25+00:00Added an answer on May 27, 2026 at 10:22 pm

    You can consolidate your code quite a bit. This will do what you want.

    Example 1

    $('html').on('click', function() {
        $('.gui-selectbox-dialog:visible').hide();
    });
    
    $('.gui-selectbox').on('click', function(event) {
        $('.gui-selectbox-dialog:visible').hide();
        $(this).find('.gui-selectbox-dialog').show();
    
        event.stopPropagation();
    });
    
    $('.gui-selectbox-dialog ul').on('click', 'li', function(event) {
        alert('selected = ' + $(this).text());
    
        event.stopPropagation();
    });
    

    Fiddle Demo: http://jsfiddle.net/tJ7Qb/

    Edit: Updated my code and demo link since I had portions using old .click() event method and some using the new .on() method. Also added an alert on option click.

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

Sidebar

Related Questions

I need to make changes to an in-use production database. Just adding a few
I need to make a custom list-style markers. Now it's done by adding element
I am making a multi-table fulltext query.But I met some question. I need make
I have a crystal report file I need make a tiny edit in. It
I need to make a WebCast presentation soon and need to do some whiteboarding
I need to make an application in .NET CF with different/single forms with a
I need to make an ArrayList of ArrayLists thread safe. I also cannot have
I need to make sure that user can run only one instance of my
I need to make a change to an ASP.NET web service written a couple
I need to make some reflective method calls in Java. Those calls will include

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.