如何按索引删除选项元素? 我想通过索引删除Elements 现在,函数将删除具有该名称的所有选定项 例: 我有: -Marco -Marco -Luca
如果我选择第一个项目,也会清除第二个项目,因为它与第一个项目具有相同的名称。
HTML:
{
"type": "extensions",
"name": "DSC",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]",
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'), '/extensions/configlcm')]"
JS:
<div class='liveexample'>
<form data-bind="submit: addItem">
New item:
<input data-bind='value: itemToAdd, valueUpdate: "afterkeydown"' />
<button type="submit" data-bind="enable: itemToAdd().length > 0">Add</button>
<input data-bind='value: itemSelected' />
<button data-bind="enable: false">Press space key to remove selected element</button>
<p>Your items:</p>
<select multiple="multiple" width="50" data-bind="options: items, click: selOpt, event: { keypress: selRemoveOpt}"> </select>
</form>
</div>