I have a select box that is being populated dynamically from a database. As of right now the population of this check box is working flawlessly.
I have added functio
Another correct way to get selected value would be using this selector:
$("option[value="0"]:selected")
Best for you!
To check whether select box has any values:
if( $('#fruit_name').has('option').length > 0 ) {
To check whether selected value is empty:
if( !$('#fruit_name').val() ) {
One correct way to get selected value would be
var selected_value = $('#fruit_name').val()
And then you should do
if(selected_value) { ... }