1.先准备界面代码:
<FORM id="form1" runat="server">
<div align="left">
<fieldset style="width: 300px; height: 200px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="width: 10px">
</td>
<td>
<p>
更新网址:</p>
<asp:radioButtonlist ID="rblurl" runat="server">
<asp:ListItemtext="新浪" value="http://www.sina.com.cn"></asp:ListItem>
<asp:ListItem Text="百度" Value="HTTP://www.bAIdu.com"></asp:ListItem>
<asp:ListItem Text="网易" Value="http://www.163.com"></asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Hyperlink ID="hyperLink" runat="server">点击这儿</asp:HyperLink>
</td>
</tr>
</table>
</fIEldset>
</div>
</Form>
2.RadioButtonList转换成<TABle/>,其成员转换为<inputtype="radio"/>,下面是实现改变URL值的脚本代码:
<head runat="server">
<title>Recipe10</title>
<script src="Scripts/JQuery.JS" type="text/javascript"></script>
<script type="text/JavaScript">
$(document).ready(function () {
$("input[type=radio]").bind("change", function () {
$("#<%=hyperLink.ClientID %>").attr("href", $(this).val());
});
});
</script>
</head>
3.实现界面效果:
5.live()和bind()函数的区别:
live()函数可以附加事件到现在的和将来的页面元素上。然而,bind()函数只能把事件附加到已经加载过的页面元素上。
也就是说bind()适合页面静态元素而live()适合页面静态和动态元素。
复制代码 代码如下:
<FORM id="form1" runat="server">
<div align="left">
<fieldset style="width: 300px; height: 200px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="width: 10px">
</td>
<td>
<p>
更新网址:</p>
<asp:radioButtonlist ID="rblurl" runat="server">
<asp:ListItemtext="新浪" value="http://www.sina.com.cn"></asp:ListItem>
<asp:ListItem Text="百度" Value="HTTP://www.bAIdu.com"></asp:ListItem>
<asp:ListItem Text="网易" Value="http://www.163.com"></asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Hyperlink ID="hyperLink" runat="server">点击这儿</asp:HyperLink>
</td>
</tr>
</table>
</fIEldset>
</div>
</Form>
2.RadioButtonList转换成<TABle/>,其成员转换为<inputtype="radio"/>,下面是实现改变URL值的脚本代码:
复制代码 代码如下:
<head runat="server">
<title>Recipe10</title>
<script src="Scripts/JQuery.JS" type="text/javascript"></script>
<script type="text/JavaScript">
$(document).ready(function () {
$("input[type=radio]").bind("change", function () {
$("#<%=hyperLink.ClientID %>").attr("href", $(this).val());
});
});
</script>
</head>
3.实现界面效果:

复制代码 代码如下:
5.live()和bind()函数的区别:
live()函数可以附加事件到现在的和将来的页面元素上。然而,bind()函数只能把事件附加到已经加载过的页面元素上。
也就是说bind()适合页面静态元素而live()适合页面静态和动态元素。







网友评论文明上网理性发言已有0人参与
发表评论: