T.S. T.S. - 1 year ago 187
jQuery Question

Get selected items value for Bootstrap's typeahead

Bootstrap just implemented a neat autocomplete feature called typeahead. I am having trouble getting the appropriate value for the text input.

For instance, I might have the following:

$('input').on('change', function(){

This does not appear to capture the selected value. Does anyone know how to get the selected value using typeahead with Bootstrap?

Answer Source

If you only had 1 on the page you could try $('ul.typeahead li.active').data('value'); but you may have have issues if there's more than 1 on a page.

I wonder if there's a reason why the input value is not set?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download