【发布时间】:2017-03-16 10:13:01
【问题描述】:
我正在寻找解决方案,但没有找到任何解决方案
我有这个代码:
<form name="frm_hs100">
<input id="hs100[1]" name="hs100[1]" type="checkbox">
<input id="hs100[2]" name="hs100[2]" type="checkbox">
</form>
$('[name^=hs100]').click(function() {
if ($(event.target).is(":checked")){
//true
}
else {
//false
}
console.log(event.target.id);
});
console.log 打印“hs100[1]”,但如何根据单击的复选框仅获得 #1 或 #2?
【问题讨论】:
-
使用 string.replace?