更新时间:2022-12-03 11:26:26
you should use Htmlhiddeninput
which contain your selected value of the dropdown than render the div
$(document).ready(function(){
$('.box').hide();
// First Way :
$('#HiddenInput').empty();
$('#HiddenInput').val($('#dropdown').val());
var value = $('#HiddenInput').val();
$('#dropdown').val(value);
$('#div' + value).show();
$('#dropdown').change(function() {
$('.box').hide();
$('#HiddenInput').val($(this).val());
$('#div' + $(this).val()).show();
});
});
Here See DEMO : http://jsfiddle.net/pXdS6/16/