现在下面的代码完美无缺,但我想默认显示所有房间 div。我该怎么做?
HTML:
<select id="room_type">
<option value="">-- Type --</option>
<option value="oneroom">One room</option>
<option value="tworoom">Two room</option>
</select>
<div id="oneroom" style="display:none">
CONTENT 1
</div>
<div id="tworoom" style="display:none">
CONTENT 2
</div>
Javascript
<script type="text/javascript">
;(function ($) {
$('#room_type').change(function(){
var location = $(this).val(),
div = $('#' + location);
$("div[id$='room']").hide();
div.show();
});
})(jQuery);
</script>