[英]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.