Nhu cầu là chúng ta sẽ có một select khi chọn mục nào thì nó hiển thị tương ứng với element, như hình bên dưới ( code dưới được xây dựng dựa trên boostrap)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <div class="asenpts-select-lists-from"> 	<h1 class="mb-3">Select lists from</h1> 	<form method="post" action="" id="select-lists-from-form" class="mt-4"> 		<div class="card" style="margin-bottom:15px;"> 			<h6 class="card-header">Select lists</h6> 			<div class="card-block"> 				 <div class="form-group">     			<label for="select-a-source">Select a source</label>                 <select class="form-control" name="select-a-source" id="select-a-source"> 					                    	<option value="self">Self (Developing)</option>                                         	<option value="fluent-crm">Fluent CRM</option>                                     </select>   				</div> 				  								<div class="form-group source" id="source-fluent-crm" style="display: block;">                  <label for="source-fluent-crm-select">Select lists from Fluent CRM</label>                     <select multiple="" class="form-control" id="source-fluent-crm-select" name="source-fluent-crm-select">                       	                    	<option value="2">List 2</option>                     	                    	<option value="3">Danh sách nhận bài viết mới</option>                     	                    </select>                 </div>                                 <div class="form-group source" id="source-self" style="display: none;">                  <label for="source-fluent-crm-select">Select lists form self (developing)</label>                     <select multiple="" class="form-control" id="source-fluent-crm-select" name="source-fluent-crm-select">                     	<option value="">Select a list</option>                     </select>                 </div> 			</div> 		</div> 		<button type="submit" class="btn btn-primary" id="select-lists-from-trigger">Save Changes</button> 	</form> </div> | 
| 1 2 3 4 5 6 7 8 9 10 | $('select#select-a-source').on('change',function(){ 				$('.asenpts-select-lists-from .form-group.source').hide(); 				var v = $("select#select-a-source").val(); 				$('#source-'+v).show(); 			}); 			$(window).on('load',function(){ 				$('.asenpts-select-lists-from .form-group.source').hide(); 				var v = $("select#select-a-source").val(); 				$('#source-'+v).show(); 			}); | 
Mọi sự sao chép xin ghi rõ nguồn là fcwordpress.net
Chuyên trang về wordpress: hướng dẫn thiết kế theme, plugin, thủ thuật wordpress
Chili Comment. Giấy phép không hợp lệ. Kích hoạt tại đây