How to select only one checkbox at a time in jquery example

How to select only one checkbox at a time in jquery example

In this post, i will tell you how to select only one checkbox from multiple checkboxes at a time by using jQuery by two ways.

This script is usefull when you need users to be able to select only one checkboxes in pages same as radio button i mean if you have group of checkboxes and you want to force user to select only one checkbox at a time then you can use this script.

I know in many cases radio buttons are "ideal" but in some cases you will need this script to check only one checkboxes from group of checkboxes.

See the example below :

  1. <html>
  2. <head>
  3. <title>how to select only one checkbox at a time in jquery</title>
  4. <script src=""></script>
  5. </head>
  6. <body>
  7. <input value="1" name="product" class="product-list" type="checkbox">Product 1
  8. <input value="2" name="product" class="product-list" type="checkbox">Product 2
  9. <input value="3" name="product" class="product-list" type="checkbox">Product 3
  10. <input value="4" name="product" class="product-list" type="checkbox">Product 4
  11. <input value="5" name="product" class="product-list" type="checkbox">Product 5
  12. <script type="text/javascript">
  13. $('.product-list').on('change', function() {
  14. $('.product-list').not(this).prop('checked', false);
  15. });
  16. </script>
  17. </body>
  18. </html>

You can also go with following script to force user to select only checkbox at a time :

  1. <script type="text/javascript">
  2. //Near checkboxes
  3. $('.product-list').click(function() {
  4. $(this).siblings('input:checkbox').prop('checked', false);
  5. });
  6. </script>

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
hatay escort nevsehir escort nigde escort kirikkale escort batman escort osmaniye escort kirklareli escort tokat escort rize escort adiyaman escort gumushane escort batman escort
porno izle
cialis satış cialis fiyat cialis 20 mg cialis 100 mg cialis 5 mg fiyat
sohbet okey oyna
ankara escort marmaris escort bursa escort mersin escort antalya escort izmir escort samsun escort bodrum escort çeşme escort kuşadası escort adana escort eskişehir escort gaziantep escort esenyurt escort pendik escort tuzla escort fatih escort ümraniye escort mecidiyeköy escort kartal escort bahçelievler escort bahçeşehir escort ataşehir escort bakırköy escort nişantaşı escort avcılar escort büyükçekmece escort kurtkoy escort konya escort beşiktaş escort taksim escort beylikdüzü escort malatya escort sakarya escort şişli escort maltepe escort kadıköy escort ataköy escort bostancı escort şirinevler escort bağcılar escort üsküdar escort etiler escort başaksehir escort ortaköy escort kağıthane escort sultangazi escort halkalı escort çekmeköy escort şaşkınbakkal escort mamak escort sincan escort keçiören escort çankaya escort beypazarı escort akyurt escort pursaklar escort kahramankazan escort göztepe escort alsancak escort bornova escort buca escort karabaglar escort karşıyaka escort konak escort narlıdere escort izmit escort başiskele escort kandira escort körfez escort karamürsel escort dilovası escort gölcük escort gebze escort kocaeli escort kayseri escort elazığ escort denizli escort diyarbakir escort adana escort ankara escort izmir escort antalya escort gaziantep escort kayseri escort konya escort mersin escort denizli escort kocaeli escort diyarbakır escort