I have a code where if you check checkbox with the same value other checkboxes with that value also checks, but I want that when it is checked also show div and if it's unchecked hide.
I tried this, but that don't work. Any help is welcome. Thank you!
$(document).ready(function(){
$('input[type="checkbox"]').click(function(){
if($('input[value="' + this.value + '"]:checkbox').prop('checked', this.checked)) {
$(".div1").show();
} else {
$(".div1").hide();
}
});
});
.div1 {
display:none;}
<script src="http://ift.tt/VorFZx"></script>
<div>
<input type="checkbox" value="one">1
<input type="checkbox" value="two">2
</div>
<div class="div1">
<p>This is text</p>
</div>
<div>
<input type="checkbox" value="one">1
<input type="checkbox" value="two">2
</div>
<div class="div1">
<p>This is another text</p>
</div>
Aucun commentaire:
Enregistrer un commentaire