【发布时间】:2019-07-19 13:35:35
【问题描述】:
我需要从具有相同类和不同值的复选框中获取值,以便在激活提交底部并选择不同的复选框时获取这些值
<script>
jQuery(.simple_search).click(function(){
if (jQuery('.skey_send').is(":checked")){
var s_key=jQuery(".skey_send").val();
alert("Value is : "+s_key);
}
});
</script>
<input type="submit" class="simple_search" name="send_s" value="GO" />
<input type="radio" name="s_key" class="skey_send" value="all" />All
<input type="radio" name="s_key" class="skey_send" value="card" />Card
<input type="radio" name="s_key" class="skey_send" value="phone" />Phone
<input type="radio" name="s_key" class="skey_send" value="price" />Price
问题总是我从第一个复选框中获得价值,但点击另一个或不同的复选框时却没有
我需要知道我需要实现什么或在我的代码中添加什么,以便在检查时从具有相同类的不同复选框中获取值
【问题讨论】:
-
分配不同的
[name]属性值,这些是无线电而不是复选框将type='radio'更改为type='checkbox