apply a size="10"
to your select.
something like:
<select size="10">
// all your options
</select>
You have to put some style to the label like border, background-image etc.
Something like this to be done:
<label id='choose' for='options'>Select options</label>
<br clear='all' />
<select id='options' size="10" style='display:none;'>
// all the options
</select>
then use this jQuery code:
$('#choose').click(function(){
$(this).siblings('select').toggle();
});
Try with this:
$('#choose').click(function (e) {
e.stopPropagation();
$(this).siblings('select').css('width', $(this).outerWidth(true)).toggle();
});
$('#options').change(function (e) {
e.stopPropagation();
var val = this.value || 'Select options';
$(this).siblings('#choose').text(val);
$(this).hide();
});
As you commented:
when size is greater then 1 of select tag, its not showing blue background in hover, when i add background through css option:hover, its working in FF, but not in chrome and safari.
so you can mockup with this:
$('#options').find('option').on({
mouseover: function () {
$('.hover').removeClass('hover');
$(this).addClass('hover');
},
mouseleave: function () {
$(this).removeClass('hover');
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…