preload
jQuery for beginners Simple Modular Arithmetic with Smarty Template Engine
Mar 20

Had enough of the same old operating system based select field style? Why not skin it up, this script allows you to apply a skin to a select box.

This tutorial is based on the original code i wrote, however this version is less buggier and has support for non JS enabled browsers!

Nice and simple to install, include the jQuery library and the select skin JS file and the CSS file like so.

<style>
<!--
@import url('./css/skinned-select.css');
//-->
</style>
<script src="./js/jquery.js" type="text/javascript"></script>
<script src="./js/jquery.skinned-select.js" type="text/javascript"></script>

Then just wrap a div with the class name of 'my-skinnable-select' around the select box, like so.

<div class="my-skinnable-select">
<select name="name">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
</select>
</div>

The form variables can be posted as usual, it's as easy as that, enjoy!

Please take a look at the demo or download the code and let me know what you think by using the contact form below.

12 Responses to “jQuery - Skinning HTML Select Boxes”

  1. HTML Select Skin . Lots of Code Says:

    [...] A more simplified version of this script is available here ... [...]

  2. Jon Says:

    Doesn't really seem to work in Opera 9.5, apart from the text color: any ideas?

  3. James Says:

    Hi, nice code - does the job I need. How do I load the select box with the selected options text in by default? E.g.;

    One
    Two
    etc..

    I need it to show "Two" when the page loads. Any ideas?

    Cheers

    James

  4. James Says:

    It's ok, I figured it out, just needed to change;

    this.options[0].innerHTML

    to

    this.options[this.selectedIndex].innerHTML

  5. DC Says:

    I tested this in mozilla and it fails to work also tested in IE6 again fails to work, what does it work in? I see only a basic select drop no skin or anything.

    Sorry but it seems to not realy be very compatable in my opin ...

    Might want to look into that.

  6. Daam Says:

    to make it work in chrome and safari, change the .click to .change. That sorted it for me.

  7. josa Says:

    its simple and easy code. its so usefull

  8. yaja Says:

    itssssssssssssssss great !!!!!!!!!!!!!!!!

  9. am Says:

    I was looking at the code to use on my website.
    Well i have three select boxes with different width.

    How to use the script with three different image widths.

    some help appreciated.

  10. Robert Says:

    Nice code. I used:

    $(function() {
    $('select').wrap('');
    });

    ...in my jQuery init to apply it to all selects in my site.

  11. Robert Says:

    Nice code... I used:

    $(function() {
    $('select').wrap('');
    });

    ...in my jQuery init to apply it to all select elements in my site.

  12. Robert Says:

    Nice code... I used:

    $(function() {
    $('select').wrap('<div class="my-skinnable-select"></div>');
    });

    ...in my jQuery init to apply it to all select elements in my site.

Leave a Reply

 
 
Please enter the word above into the box below, the word is not case sensitive.
 
If you have trouble reading the word above then click here to load a new word.
Security word: