Is there any easy way to add a style to a select box in a form using jQuery?
<select>
<option>sample</option>
<option>sample1</option>
</select>
Thanks.
Is there any easy way to add a style to a select box in a form using jQuery?
<select>
<option>sample</option>
<option>sample1</option>
</select>
Thanks.
You can alternatively use jQuery.SimpleSelect, which is nothing less than a very simple and lightweight (1.75kb gzipped) plugin that will transform your <select> elements into a bunch of divs you'll be able to style however you want using CSS.
It's as simple as that:
HTML
<select>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
JavaScript
$("select").simpleselect();
And (with default styles that you can obviously customize), it gives you this:
Try easy styling select box using jquery
<select class="selectboxdiv">
<option>choose preset...</option>
<option>two</option>
<option>something</option>
<option>4</option>
<option>5</option>
</select>
<div class="out"></div>
You cannot style the <select> node but you can visually represent styled <ul> node that it is a dropdown menu. Just When the page loads hide the original dropdown menu and create one by forming a list by <ul> tag. And when the user click on <li> node then change also the value of <select> tag.
There is no easy way to style form elements in general to be consistent across browsers. But you could go for plugins like Uniform
You cannot style the <select> tag. Trying wrapping them around with some HTML and you can style/script your HTMLs as you need.
You can do something like this (in jQuery), wrap your <select> with some markup,
<div class="selectBox">
<ul>
<li></li>
<li></li>
</ul>
<select>
<option></option>
<option></option>
</ul>
</div>
And then map <li> changes to <option> changes in your script.