Checkbox yang terpilih saja dengan jquery, secara agak sederhana
Sebelumnya kayaknya gampang pemakaian checkbox terpilih saja sederhanatapi ternyata semua checkbox kena semua, padahal di form tersebut banyak memakai checkbox, berikut supaya nggak lupa kalau dipakai lagi adalah seperti ini.
😐
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type="checkbox" class="chk" />class chk <input type="checkbox" class="chk" />class chk <input type="checkbox" class="chk" />class chk <input type="checkbox" class="chk" />class chk <br> <input type="checkbox" class="chk1" />class chk1 <input type="checkbox" class="chk1" />class chk1 <input type="checkbox" class="chk1" />class chk1 <input type="checkbox" class="chk1" />class chk1 <br> <input type="checkbox" id="chk2" />id chk2 <input type="checkbox" id="chk2" />id chk2 <input type="checkbox" id="chk2" />id chk2 <input type="checkbox" id="chk2" />id chk2 <script> $('input.chk').on('change', function() { $('input.chk').not(this).prop('checked', false); }); </script> <script> $('input.chk1').on('change', function() { $('input.chk1').not(this).prop('checked', false); }); </script> <script> $('input#chk2').on('change', function() { $('input#chk2').not(this).prop('checked', false); }); </script>
No similar posts
Langganan:
Posting Komentar
(
Atom
)
Tidak ada komentar :
Posting Komentar