我需要在列表框中的CheckBoxes中添加ID
<input type=”checkbox” name=”vehicle” id = 1>Code</br>
<input type=”checkbox” name=”vehicle” id = 2>Select
一旦我选择CheckBox并且我需要获取CheckBox ID,我也可以勾选CheckBox基于ID如何做????
但这里不能添加
var source = [
"Affogato",
"Caffé Latte"];
// Create a jqxListBox
$(“#jqxListBox”).jqxListBox({
source: source,
theme: ‘energyblue’,
width: ’200px’,
height: ’250px’,
checkboxes:true
});
答案 0 :(得分:1)
您可以使用checkChange
事件,在您的情况下,源应该有两个值(1 - displayMember,2 - valueMember):
var source = [{
vehicle: "Affogato",
id: 122
}, {
vehicle: "Americano",
id: 156
}, {
vehicle: "Bicerin",
id: 1023
}, {
vehicle: "Breve",
id: 4567
}];
$("#jqxListBox").jqxListBox({
source: source,
displayMember: "vehicle",
valueMember: "id",
checkboxes: true
});
$("#jqxListBox").on('checkChange', function (event) {
var args = event.args;
// get new check state.
var checked = args.checked;
// get the item and it's label and value fields.
var item = args.item;
var itemLabel = item.label;
var itemValue = item.value;
});
尝试此操作以提供帮助:https://jsfiddle.net/charlesrv/YnqPP/31/