如何使用Jquery将多个选定的复选框项目放入列表框中 [英] How Do I Get Multiple Selected Checkbox Item Into A Listbox Using Jquery
本文介绍了如何使用Jquery将多个选定的复选框项目放入列表框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码用于将多个选中的项目添加到MVC5列表框但是它不起作用
i have this code for adding multiple checked item to MVC5 Listbox but it is not working
$('#addRecipientList').click(function () {
var chkBox = $('#chooseRecipient').val();
var isChecked = $('#chooseRecipient').is(":checked");
var lst = $("#recipientList");
var options = $("#recipientList option");
var arr = [];
var alreadyExist = false;
if (isChecked) {
$(options).each(function () {
if ($(this).val() == chkBox) {
$("#errormsg").text('Mobile Number already exist')
//alert("Mobile Number already exists");
alreadyExist = true;
uncheck();
$('#loginForm').hide();
$("#errormsg").fadeOut(5000);
$('#chooseRecipient').checked = false;
return;
}
});
if (!alreadyExist)
$(lst).append('<option value="' + chkBox + '">' + chkBox + '</option>');
return true;
}
});
请问有什么我想念的吗?
帮助,谢谢您的时间
please is there anything i am missing?
help please thank you for your time
推荐答案
(' < span class =code-string>#addRecipientList')。click( function (){
var chkBox =
('#addRecipientList').click(function () { var chkBox =
(' #chooseRecipient')。val();
var isChecked =
('#chooseRecipient').val(); var isChecked =
(' #chooseRecipient')。是( :checked);
var lst =
('#chooseRecipient').is(":checked"); var lst =
这篇关于如何使用Jquery将多个选定的复选框项目放入列表框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文