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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:42:28+00:00 2026-06-15T18:42:28+00:00

I have a select box that I’ve put a span near so it looks

  • 0

I have a select box that I’ve put a span near so it looks like:

___________________          ___________________
| Sort By: opt1 v |    ->    | Sort By: opt1 v |
|_________________|          |_________________| 
                             :.......opt2......:
                             :.......opt3......:

instead of:

        ___________                    __________
Sort By:|  opt1 v |    ->      Sort By:| opt1 v |
        |_________|                    |________| 
                                       :..opt2..:
                                       :..opt3..:

See my jsfiddle. It has all the html, css and jquery I’m attempting to use.

The Problem:
The select box only engages when you click on the visible option name. I need to transfer the click on the spans (one contains “Sort By:” and the other has a custom dropdown arrow img) to a click on the select element. Here’s what I’ve tried:

$('span').click(function(){
    var sb = $('select');
    //none of these work! Please help!
    sb.select();
    sb.click();
    sb.focus();
});

Some disclaimers:

  • I don’t want to select a specific option. I want to OPEN the selectbox and see all the options, just as if I had clicked on the selectbox.
  • I’m not allowed to use the jquery plugin selectbox.
  • 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-15T18:42:29+00:00Added an answer on June 15, 2026 at 6:42 pm

    What you can do is creating a background image on the select box that contains the text as well as the arrow. Using appearance: none, the native arrow is not drawn, and with some left/right padding you can pretty much achieve what you want. Note that this probably is not cross-browser, so make sure to test it: http://jsfiddle.net/5xcHm/16/.

    Some canvas code to create background image:

    var w = $(".sb").outerWidth();
    var h = $(".sb").outerHeight();
    
    var canvas = $("<canvas>").attr({
        "width": w,
        "height": h
    }).get(0);
    var ctx = canvas.getContext("2d");
    
    $.extend(ctx, {
        font: "9pt sans-serif",
        textBaseline: "middle"
    });
    
    ctx.fillText("Sort By:", 5, h/2+1);
    
    ctx.moveTo(w - 15, 5);
    ctx.lineTo(w - 5, 5);
    ctx.lineTo(w - 10, 15);
    ctx.closePath();
    ctx.fill();
    
    var url = canvas.toDataURL("image/png");
    $(".sb").css("background-image", "url(%)".replace("%", url));
    

    And the CSS:

    .sb {
        -webkit-appearance: none;  /* mind the prefixes */
        padding-left: 55px;
        padding-right: 15px;
        position: absolute;
        background-repeat: no-repeat;
        background-position: left center;
    }
    .sortOptionContainer {
        position: relative;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select box that looks like this (within a form_for) <%=f.select(:whatever_id, {blah=>0,
I have a select box on a classic ASP page which looks like this:
I have a select box that is being populated dynamically from a database. As
I have a select box that needs to submit it's value to a server
I am using chosen.js ( http://harvesthq.github.com/chosen/ ) and I have a select box that
here is my situation. I have a select box that is populated from a
I want to have on my site a single select box that will then
I have a select box on a page that does a post with jQuery
We have a custom JSF component that renders some buttons and a select box
I have a select box that gets generated dynamically. I want to allow users

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.