Bootstrap-select: How do I get the select value?

Created on 19 Jan 2014  路  4Comments  路  Source: snapappointments/bootstrap-select

I use for an select tag with class='selectpicker' and id="select1",

then $('.selectpicker').selectpicker();

When I select an option, the source element (that hidden) does not set "selected" to relate option, so I dont know how to get the value/text of selected item.

Most helpful comment

@spyhunter88, try this: http://jsfiddle.net/5Gncw/

var val = $('.selectpicker').val();

All 4 comments

try jQuery val()

I tried but value is "undefined". See here: http://jsfiddle.net/spyhunter88/dxJkX/

@spyhunter88, try this: http://jsfiddle.net/5Gncw/

var val = $('.selectpicker').val();

Sorry, I made dummy mistake in id with dot ('.'), Thanks.

Was this page helpful?
0 / 5 - 0 ratings