我想得到所有的输入:
那些是复选框,
被检查和
具有包含“-required”的类名。
我有这个,并尝试了几种变体,但没有任何效果:
$("input:checkbox[class*='-required']:checked");
示例 html:
<form name="myform" method="POST">
<div id="checkFruits">FRUITS: </div>
<input type="checkbox" id="chkFruit" class="chkFruit test-234-required" name="fruit" value="Apples" />Apples <br />
<input type="checkbox" id="chkFruit" class="chkFruit test-234-required" name="fruits" value="Oranges" />Oranges <br />
<input type="checkbox" id="chkFruit" class="chkFruit test-234-required" name="fruits" value="Pears" />Pears <br />
<input type="checkbox" id="chkFruit" class="chkFruit test-234-required" name="fruits" value="Grapes" />Grapes <br /><br />
<input type="button" id="btnCheckFruit" value="Check Fruits" name="btnCheckFruit" />
<hr />
<div id="checkCars">CARS: </div>
<input type="checkbox" id="chkCar" class="chkCar" name="fruit" value="Lexus" />Lexus <br />
<input type="checkbox" id="chkCar" class="chkCar" name="fruits" value="Maxima" />Maxima <br />
<input type="checkbox" id="chkCar" class="chkCar" name="fruits" value="Cadillac" />Cadillac <br />
<input type="checkbox" id="chkCar" class="chkCar" name="fruits" value="Lincoln" />Lincoln <br /><br />
<input type="button" id="btnCheckCar" value="Check Cars" name="btnCheckCar" />
<hr />
<ul>
<li>foo</li>
<li>bar</li>
</ul>
</form>