Open vohrahul opened 6 years ago
I managed to work out a way to get the selected value for anyone in the future:
You can add this else if
statement to the Methods conditionals.
}else if (method == 'selected') {
return $(this).next().find('.selected').text();
}else if (method == 'val') {
return $(this).next().find('.selected').attr('data-value');
You can then call it like:
var n_select = $('.n-select').niceSelect();
n_select.niceSelect('selected'); //returns text
n_select.niceSelect('val'); //returns value
Which will return the text of the current selected option.
I think maybe u can try this ....
$('#select1').next().find('li.selected').attr('data-value')
i just found...
$('id').val()
is ok ...
@hernansartorio
$('#original_select_id').val()
doesn't work.In the documentation, there's no way to get the selected value. Do I have to always traverse the DOM to get the data-value attribute of the list item?
Pre-added function would be such a great gift to this plugin.
Thanks