Checkbox data-bind返回两个值?

时间:2017-04-08 04:12:51

标签: javascript ajax

我正在尝试获取ID和复选框状态(我将CSS作为Button CSS Button

按钮名称,如果有效

<div class="onoffswitch">
<input type="checkbox" data-bind="checked: ioValue" class="onoffswitch-checkbox" id="io1">
    <label class="onoffswitch-label" for="io1">
    <span class="onoffswitch-inner"></span>
    <span class="onoffswitch-switch"></span>
</label>

                                    

按钮工作并显示true false,我无法弄清楚如何获取ID

 self.ioEvent = function(data, event) {
           console.log(1)
           console.log(data)

           console.log(data[0])
           console.log(data[1])

           $.ajax({
                type: "GET",
                dataType: "json",
                data: {"io": data[0], "status": data[1]},
                url: "/plugin/test/setIOcheckbox",       
                async: false
        });
    }

1 个答案:

答案 0 :(得分:1)

event.target.id 应该为您提供&#34; ID&#34;