选择所有在jquery中选择的插件



我正在尝试选择所有使用所选插件,但我在所有尝试中都失败了。我正在使用以下代码。任何帮助都将非常感激。我使用'select all'并删除所有'与chosen.js

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" type="image/jpg" href="hanken_logo.jpg">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="chosen/chosen.min.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="css/bootstrap.min.css?v=<?php echo time(); ?>">
<title>Data Portal</title>
</head>
<body>
<div class="Header">
<p class="Message">Data</p>>
</div>
<div class="container_data">
Select Variables
<select multiple data-placeholder="Select..." class="chosen-select">
<option hidden selected value=""></option>
<option value="1">Firm Size</option>
<option value="2">Firm Age</option>
<option value="3">Market-to-Book</option>
<option value="4">Return on Assets</option>
<option value="5">Return on Equity</option>
</select>
<button class="select">Select all</button>
<button class="deselect">Deselect all</button>
<script src="jquery/jquery.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="chosen/chosen.jquery.min.js"></script>
<script type="text/javascript">
$('select').chosen();
$('.select').click(function(){
$('option').prop('selected', true);
$('select').trigger('liszt:updated');
});
$('.deselect').click(function(){
$('option').prop('selected', false);
$('select').trigger('liszt:updated');
});​
</script>
</p>
</div>
</body>
</html>

$('select').trigger('liszt:updated');改为$('select').trigger('chosen:updated');

相关内容

  • 没有找到相关文章

最新更新