如何将下面的单选按钮的值传递给copy_select_val()函数?jQuery:传递选择单选按钮的值
<input type="radio" name="selected_invoice" value="35" onclick="copy_select_val(); return false;">
如何将下面的单选按钮的值传递给copy_select_val()函数?jQuery:传递选择单选按钮的值
<input type="radio" name="selected_invoice" value="35" onclick="copy_select_val(); return false;">
尝试this.value
到电台的价值传递给你的函数:
<input type="radio" name="selected_invoice" value="35"
onclick="copy_select_val(this.value); return false;">
function copy_select_val() {
alert($(this).val());
}
但我不是用户如果将内联处理类似的onclick也行。为什么你不在这个按钮上设置点击事件监听器?
像这样:
<input type="radio" name="selected_invoice" value="35"
onclick="copy_select_val(this.defaultValue); return false;">
jQuery是关于是联合国侵入。这意味着,你不需要直接在html元素中使用Javascript。这就是说,你可以这样做:
$("input[name='selected_invoice']:checked").val();
如果你使用的是jQuery,你应该把javascript保留在html之外。
理解并将实施! – stef 2010-01-27 21:48:10