jquery获取值的问题?
页面a.aspx
html:
<input name="Type" id="rdo" type="radio" value="0" checked="checked" onclick="ChangeType()"/><label>0</label><input name="Type" type="radio" value="1" id="rdo1" onclick="ChangeType()"/><label>2</label>
<div id="divHide" style="display:none">
<input name="sType" type="radio" value="1" id="srdo1" checked="checked"/><label>Attend</label><input name="sType" id="srdo2" type="radio" value="2" /><label>Agree</label><input name="sType" id="srdo3" type="radio" value="3"/><label>Approve</label>
</div>
<div><input type="button" id="btnSubmit" name="btnSubmit" onclick="GetSubmit()"></div>
js代码:
var Type = "";
function ChangeType() {
Type = $("input[@name=Type]:checked").val();
if (Type == "0") {
$("#divHide").attr("style", "display:none");
}
else {
$("#divHide").attr("style", "display:block");
}
}
function GetSubmit()
{
if (Type == "1") {
Re = $("input[@name=sType]:checked").val();
}
alert(Re); ----- 为何打印出来的,总是 1 ...当我选择了Agree的这项..
}
求解..谢谢.
------解决方案--------------------function GetSubmit()
{
if (Type == "1") {
Re = $("input[@name=sType]:checked").val();
}
alert(Re);
改成
function GetSubmit()
{
if (Type == "1") {
Re = $("input[name='sType']:checked").val();
}
alert(Re); }
就可以
------解决方案--------------------var Type = "";
function ChangeType() {
Type = $("input[name='Type']:checked").val();
if (Type == "0") {
$("#divHide").attr("style", "display:none");
}
else {
$("#divHide").attr("style", "display:block");
}
}
function GetSubmit()
{
if (Type == "1") {
Re = $("input[name='sType']:checked").val();
}
alert(Re);
}
------解决方案--------------------Re = $("input[@name=sType]:checked").val();
==>
Re = $("input[name='sType']:checked").val();