如何爲兩個或更多選項使用jQuery代碼? 我的代碼:如何爲兩個或更多選項使用jQuery代碼?
jQuery(document).ready(function($) { jQuery('#select123' || '#select12').change(function() { jQuery('.content123' || '.content13').hide(); jQuery('#' + jQuery(this).val()).show(); }).trigger("change"); });
div.content123,div.content13 { display: none }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select id="select123"> \t <option value="content1" selected="selected">content1</option> \t <option value="content2">content2</option> \t </select> <div id="content1" class="content123"> \t text defult show </div> <div id="content2" class="content123"> \t contentttttttt </div> <select id="select12"> \t <option value="content01" selected="selected">content1</option> \t <option value="content02">content2</option> \t </select> <div id="content01" class="content13"> \t text defult show </div> <div id="content02" class="content13"> \t contentttttttt </div>
閱讀API文檔必須讓你回答這個自己 – charlietfl