简体   繁体   English

如何通过jquery或javascript获取复选框输入值?

[英]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.现在,我想在单击copy the checked link按钮时执行此操作。 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/ http://jsfiddle.net/t5TKm/

You can't copy to the clipboard without flash, silverlight, or some other rich-client plugin.如果没有 flash、silverlight 或其他一些富客户端插件,您将无法复制到剪贴板。

But, here is the answer to that question: How do I copy to the clipboard in JavaScript?但是,这是该问题的答案: 如何复制到 JavaScript 中的剪贴板?

And: How to retrieve checkboxes values in jQuery并且: 如何检索 jQuery 中的复选框值

You can use the document.getElementByTag('VD10').checked to check if the checkbox is checked or not您可以使用document.getElementByTag('VD10').checked来检查复选框是否被选中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在数组中获取选中的复选框和关联的文本框值,然后使用jquery或javascript将此值附加到url - How to get checked checkbox and associated text box value in an array and append this value to url using jquery or javascript 如何使用Javascript或Jquery选中复选框值并显示到输入元素? - How to get checkbox value checked and show to input element using Javascript or Jquery? 如何在 JavaScript 中获取检查的行输入字段值? - How can i get checked row input field value in JavaScript? 如何在 javascript/jquery 中获得选中的复选框标题值? - How can i get a checked Checkbox title value in javascript/jquery? 如何使用JavaScript / JQuery在Gridview中获取复选框检查值 - How to get checkbox checked value inside Gridview using JavaScript / JQuery 在javascript / jquery中获取多个检查值 - get multiple checked value in javascript/jquery javascript / jquery获取新选中的复选框的值 - javascript/jquery get value of newly checked checkbox 使用Mysql在CodeIgniter中使用Jquery获取Checked框输入值 - Get the Checked box input values using Jquery in CodeIgniter using Mysql 如何使用javascript / jQuery将值分配给动态创建的输入框 - How to assign value to dynamically created input box using javascript/Jquery 如何使用javascript / jquery获取数组中选中和未选中的复选框值 - how to get checked and unchecked check box values in an array using javascript/jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM