How to retrieve checkboxes values in jQuery

前端 未结 15 2320
时光说笑
时光说笑 2020-11-22 10:11

How to use jQuery to get the checked checkboxes values, and put it into a textarea immediately?

Just like this code:


  
  &l         


        
15条回答
  •  礼貌的吻别
    2020-11-22 11:01

    Anyway, you probably need something like this:

     var val = $('#c_b :checkbox').is(':checked').val();
     $('#t').val( val );
    

    This will get the value of the first checked checkbox on the page and insert that in the textarea with id='textarea'.

    Note that in your example code you should put the checkboxes in a form.

提交回复
热议问题