function selects(num) { if ($('#s' + num).val()) { return $('#s' + num).val(); } else { return selects($('#s' + num - 1); } }
function pick_select_value(){ for (var i = $("select").length - 1; i >= 0; i--) { if ($("select").eq(i).find("option:selected").val()) { return $("select").eq(i).find("option:selected").val(); break; } } }
$('#s3').val() || $('#s2').val() || $('#s1').val();
<option>1</option>
<option>2</option>
<option>3</option>
</select>$("#select1 option:selected").val();第二级和第三级同理
function selects(num) {
if ($('#s' + num).val()) {
return $('#s' + num).val();
} else {
return selects($('#s' + num - 1);
}
}
for (var i = $("select").length - 1; i >= 0; i--) {
if ($("select").eq(i).find("option:selected").val()) {
return $("select").eq(i).find("option:selected").val();
break;
}
}
}