关注链接Jquery for pass selected radio button value on button click。它正在为我工作。
在上面的问题中,我想传递值(并显示在下拉框和文本框中)单击按钮单击而不是单击按钮。如何可能。
答案 0 :(得分:1)
试试这个
"<input type="radio" name="joblist" onclick="myfunc(this);" id= ' + value.jobid + 'value=' + value.jobid + '/>"
function myfunc(ele){
var $tr=$(ele).parent().parent(); ....
//the rest of the code
}
选择你想要的那个。
$("#OS option").each(function(){
if($(this).val()==os)
$(this).attr('selected','selected');
else
$(this).removeAttr('selected');
});
答案 1 :(得分:0)
<强> DEMO 强>
试试这个
$(document).ready(function() {
$("input[type='radio']").click(function () {
alert($(this).val());
});
});
和单选按钮HTML
<input type="radio" value="male" name="sex" />male
<input type="radio" value="female" name="sex" />female
希望这有帮助,谢谢