我有不太多的复选框:
<input type="checkbox" id="mango" value="mango" /> <label>MANGO</label><br>
<input type="checkbox" id="santol" value="santol" /> <label>SANTOL</label><br>
<input type="checkbox" id="guava" value="guava" /> <label>GUAVA</label><br>
<input type="checkbox" id="lomboy" value="lomboy" /> <label>LOMBOY</label><br>
<input type="checkbox" id="apple" value="apple" /> <label>APPLE</label><br>
<input type="checkbox" id="orange" value="orange" /> <label>ORANGE</label><br>
...................<>
现在,我想要做的是获取所有已经被选中和未选中的复选框的ID,并将其放入一个数组中。类似于这样:
"fruitsGranted":["apple","lomboy","orange"]; //check is true
"fruitsDenied":["mango","santol","guava"]; //check false
能否有人向我展示如何做呢?谢谢。
fruitsGranted
和fruitsDenied
? - jayAnnalert( someObj.fruitsGranted.join(",") );
- naveen{}
是一个空对象。 - James Montagne