简体   繁体   中英

how to get the checked box input value by jquery or javascript?

the input check box code:

<li class="odd"><input type="checkbox"  class="forminput" name="VD10" checked="checked" value="http://test1.com">
<a href="#">example 1</a></li>

<li class="even><input type="checkbox"  class="forminput" name="VD11" checked="checked" value="http://test2.com">
<a href="#">example 1</a></li>

<li class="odd"><input type="checkbox"  class="forminput" name="VD12" checked="checked" value="http://test3.com">
<a href="#">example 1</a></li>........

the button code:

<li>
<input type="checkbox" id="checkall" name="checkall" checked="checked"> 
<label for="checkall">check all</label>
<input type="button" value="copy the checked link" class="button">
</li>

now, i want to do when click the copy the checked link button. it will copy the checked input value to the clipboard? how do i do?

Try this,

$(".button").click( function () {
           var selectedCheckboxValue = "";
          $('input.forminput:checked').each(function() {

                  selectedCheckboxValue += $(this).val() + ", ";

          });
          alert(selectedCheckboxValue);
   });

click here see the working demo. http://jsfiddle.net/t5TKm/

You can't copy to the clipboard without flash, silverlight, or some other rich-client plugin.

But, here is the answer to that question: How do I copy to the clipboard in JavaScript?

And: How to retrieve checkboxes values in jQuery

You can use the document.getElementByTag('VD10').checked to check if the checkbox is checked or not

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM