我有以下多个选择标记和脚本:
$('#prod11').on('change', function() {
var selected = $(this).find('option:selected', this);
var results = [];
selected.each(function() {
results.push($(this).data('email'));
});
alert(results);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select class="selectpicker w-100" multiple="" id="prod11" name="prod[]" data-style="form-control-lg btn-info" tabindex="-98">
<option selected disabled> בחר מפיק</option>
<option value=""> </option>
<?php foreach ($prod_res as $prod) : ?>
<option value="<?= $prod['user_first'] ?> <?= $prod['user_last'] ?>" phone="<?= $prod['user_phone']?>" email="<?= $prod['user_email'] ?>" data-id="<?= $prod['user_id'] ?>">
<?= $prod['user_first'] ?>
<?= $prod['user_last'] ?>
</option>
<?php endforeach; ?>
</select>
<input type="hidden" name="prod_email[]" class="prod_email">
<input type="hidden" name="prod_phone[]" class="prod_phone">
<input type="hidden" name="prod_id[]" class="prod_id">
我正在尝试获取电话电子邮件和数据ID的属性,但我得到的只是undefined
,我尝试了几种脚本,但是它们都没有用,
我正在使用引导selectpicker
类,