您的位置:首页 > Web前端 > JQuery

ASP.NET jQuery 随笔 显示RadioButtonList成员选中的内容和值

2013-12-12 15:14 776 查看
通过jQuery来获取RadioButtonList成员内容。

<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="Web.Default"%>

[code]
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title></title>

<scriptsrc="jquery-1.8.2.min.js"type="text/javascript"></script>

<linkhref="Base.css"rel="stylesheet"type="text/css"/>

<styletype="text/css">


</style>

<scripttype="text/javascript">

$(document).ready(function(){

$("#<%=rblHobbies.ClientID%>input[type=radio]").bind("change",function(){

if($(this).val()!=""){

$("#message").text("Text:"+$(this).next().text()+"Value:"+$(this).val());

}


});

});


</script>

</head>

<body>

<formid="form1"runat="server">

<divstyle="margin:100pxauto;width:400px;height:200px;">

<fieldsetstyle="width:400px;height:150px">

<p>

请选择爱好</p>

<asp:RadioButtonListID="rblHobbies"runat="server">


<asp:ListItemValue="1">音乐</asp:ListItem>

<asp:ListItemValue="2">篮球</asp:ListItem>

<asp:ListItemValue="3">美剧</asp:ListItem>

<asp:ListItemValue="4">电影</asp:ListItem>


</asp:RadioButtonList>

</fieldset>

<br/>

<divid="message"style="color:blue;"></div>

</div>

</form>

</body>

</html>

[/code]



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: