Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile <select> produces extra 'ui-btn-text'

I have the below code

<select id="country">
    <option value="1">Atlanta</option>
    <option value="2">Berlin</option>
</select>

but it seems to be generating the below markup

<div class="ui-select"><div data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="arrow-d" data-iconpos="right" data-theme="c" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-right ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text"><span>Atlanta</span></span><span class="ui-icon ui-icon-arrow-d ui-icon-shadow">&nbsp;</span></span>
<select id="country">
    <option value="1">Atlanta</option>
    <option value="2">Berlin</option>
</select>
</div></div>

and the problem with this is that it is producing an extra span with my selected text in front of the dropdown list. How do I remove that span with selected text?

like image 402
chongzixin Avatar asked Nov 19 '25 13:11

chongzixin


1 Answers

Just add a:

data-role="none" 

to your select element. This way your select box will not be enhanced.

Working example: http://jsfiddle.net/Gajotres/PMrDn/60/

This will of course prevent select from been styled. What I want to tell is there's no point in removing this span. Without it custom select box styles can't be shown, even more your original select is hidden so you will see absolutely nothing. This goes only if you want to have a custom select box, in any other case data-role="none" is what you want.

like image 176
Gajotres Avatar answered Nov 21 '25 02:11

Gajotres



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!