开发者

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</labe开发者_运维知识库l>
<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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜