admin管理员组文章数量:1026989
I want to get checkbox
value using jQuery when to uncheck the checked checkbox and show that unchecked value in the popup. I've tried below code but it not work
$("#countries input:checkbox:not(:checked)").click(function(){
var val = $(this).val();
alert('uncheckd' + val);
});
Is it possible to get unchecked value in this way?
I want to get checkbox
value using jQuery when to uncheck the checked checkbox and show that unchecked value in the popup. I've tried below code but it not work
$("#countries input:checkbox:not(:checked)").click(function(){
var val = $(this).val();
alert('uncheckd' + val);
});
Is it possible to get unchecked value in this way?
Share Improve this question edited Aug 31, 2017 at 9:25 always-a-learner 3,79410 gold badges45 silver badges87 bronze badges asked Dec 3, 2014 at 6:44 MiurangaMiuranga 2,46310 gold badges53 silver badges81 bronze badges3 Answers
Reset to default 61Your selector will only attach event to element which are selected in the beginning. You need to determine check unchecked state when value is changed:
$("#countries input:checkbox").change(function() {
var ischecked= $(this).is(':checked');
if(!ischecked)
alert('uncheckd ' + $(this).val());
});
Working Demo
You should check the condition on click or change. I hope that my example will help you.
$("input:checkbox.country").click(function() {
if(!$(this).is(":checked"))
alert('you are unchecked ' + $(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input class="country" type="checkbox" name="country1" value="India" /> India </br>
<input class="country" type="checkbox" name="country1" value="Russia" /> Russia <br>
<input class="country" type="checkbox" name="country1" value="USA" /> USA <br>
<input class="country" type="checkbox" name="country1" value="UK" /> UK
$("#countries input:checkbox").on('change',function()
{
if(!$(this).is(':checked'))
alert('uncheckd ' + $(this).val());
});
I want to get checkbox
value using jQuery when to uncheck the checked checkbox and show that unchecked value in the popup. I've tried below code but it not work
$("#countries input:checkbox:not(:checked)").click(function(){
var val = $(this).val();
alert('uncheckd' + val);
});
Is it possible to get unchecked value in this way?
I want to get checkbox
value using jQuery when to uncheck the checked checkbox and show that unchecked value in the popup. I've tried below code but it not work
$("#countries input:checkbox:not(:checked)").click(function(){
var val = $(this).val();
alert('uncheckd' + val);
});
Is it possible to get unchecked value in this way?
Share Improve this question edited Aug 31, 2017 at 9:25 always-a-learner 3,79410 gold badges45 silver badges87 bronze badges asked Dec 3, 2014 at 6:44 MiurangaMiuranga 2,46310 gold badges53 silver badges81 bronze badges3 Answers
Reset to default 61Your selector will only attach event to element which are selected in the beginning. You need to determine check unchecked state when value is changed:
$("#countries input:checkbox").change(function() {
var ischecked= $(this).is(':checked');
if(!ischecked)
alert('uncheckd ' + $(this).val());
});
Working Demo
You should check the condition on click or change. I hope that my example will help you.
$("input:checkbox.country").click(function() {
if(!$(this).is(":checked"))
alert('you are unchecked ' + $(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input class="country" type="checkbox" name="country1" value="India" /> India </br>
<input class="country" type="checkbox" name="country1" value="Russia" /> Russia <br>
<input class="country" type="checkbox" name="country1" value="USA" /> USA <br>
<input class="country" type="checkbox" name="country1" value="UK" /> UK
$("#countries input:checkbox").on('change',function()
{
if(!$(this).is(':checked'))
alert('uncheckd ' + $(this).val());
});
本文标签: JavaScriptJQueryHow get checkbox unchecked event and checkbox valueStack Overflow
版权声明:本文标题:javascript - Jquery, How get checkbox unchecked event and checkbox value? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1737218905a1450477.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论