因此,這是問題所在。我編寫了一個基於所選下拉菜單打開div的代碼。這很好。然後我想要預先選擇一個特定的選項($ _POST ['value'])。這很好。問題出現在我還想讓相關div打開的時候。我可以做一個或另一個,但從來沒有在一起。請注意,我包含了工作選項並對其進行了評論。請告訴我什麼是我應該做的事:無法同時在jquery中同時使用這兩個操作
$(document).ready(function(){
$('.box').hide();
$('#sow').change(function() {
$('.box').hide();
$('#div' + $(this).val()).show();
});
});
var theText = "Printer Setup";
//$("#sow option:contains(" + theText + ")").attr('selected', 'selected');
//$("#sow option:contains(" + theText + ")")$('#divoption5').show();
$("#sow option:contains(" + theText + ")").attr('selected', 'selected')$('#divoption5').show();
會需要更多的代碼 – j08691