【发布时间】:2018-11-20 15:19:26
【问题描述】:
我正在尝试制作一个没有复选框的网站,而 jQuery Select2 似乎就是答案。现在,我无法根据多个 Select2 选择显示多个 div。例如,如果在我的下拉列表中选择了 OnBase,我想显示 OnBase div,如果未选择 OnBase,则将其隐藏。
Script to hide my Divs
<script>
$(document).ready(function() {
$('.selectapps').select2();
$('#CNKronos').hide();
$('#Network2').hide();
$('#Network').hide();
$('#OnBase').hide();
});
</script>
Script that only shows the div for the first selection only
<script>
$(function() {
$('#ApplicationsList').change(function(){
$('.selectapps2').hide();
$('#' + $(this).val()).show();
});
});
</script>
Select2 Dropdown
<div id="Applications" class="panel panel-primary" style="width:850px; margin:0 auto; margin-top:10px;">
<div class="panel-heading">
<h3 class="panel-title"><strong>Applications</strong></h3>
</div>
<div class="panel-body">
<table width="825" border="0" class="table table-striped">
<tbody>
<tr>
<td>
<select class="selectapps selectapps2" id="ApplicationsList" name="ApplicationsList" multiple="multiple" style="width:99%;">
<option value="CNKronos" >CNKronos</option>
<option value="Network2">Drive</option>
<option value="Network">Email</option>
<option value="OnBase">OnBase</option>
</select>
</td>
</tr>
</tbody>
</table>
</div>
</div>
DIVS
<div id="CNKronos" class="panel panel-primary selectapps2" style="width:850px; margin:0 auto; margin-top:10px;">
<div class="panel-heading">
<h3 class="panel-title"><strong>CNKronos</strong></h3>
</div>
<div class="panel-body">
<table width="825" border="0" class="table table-striped">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="Network2" class="panel panel-primary selectapps2" style="width:850px; margin:0 auto; margin-top:10px;">
<div class="panel-heading">
<h3 class="panel-title"><strong>Drive</strong></h3>
</div>
<div class="panel-body">
<table width="825" border="0" class="table table-striped">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="Network" class="panel panel-primary selectapps2" style="width:850px; margin:0 auto; margin-top:10px;">
<div class="panel-heading">
<h3 class="panel-title"><strong>Email</strong></h3>
</div>
<div class="panel-body">
<table width="825" border="0" class="table table-striped">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="OnBase" class="panel panel-primary selectapps2" style="width:850px; margin:0 auto; margin-top:10px; ">
<div class="panel-heading">
<h3 class="panel-title"><strong>OnBase</strong></h3>
</div>
<div class="panel-body">
<table width="825" border="0" class="table table-striped">
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div> '
你能帮我实现这个吗?我要疯了,找不到任何其他解决方案。
谢谢
【问题讨论】:
标签: javascript jquery html jquery-select2 jquery-select2-4