ASP.NET jQuery 实例10 动态修改hyperlink的URL值
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ASP.NET jQuery 实例10 动态修改hyperlink的URL值,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1440字,纯文字阅读大概需要3分钟。
内容图文
![ASP.NET jQuery 实例10 动态修改hyperlink的URL值](/upload/InfoBanner/zyjiaocheng/369/97339a334c954748a3b1fc1e3969e78f.jpg)
代码如下:
<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:ListItem Text="新浪" 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/>,其成员转换为<input type="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.实现界面效果:
4.另外我们可以通过下面的代码实现绑定change事件:
代码如下:
$("input=[type=radio]").live("change", function(){
$("a").attr("href", $(this).val());
});
5.live()和bind()函数的区别:
live()函数可以附加事件到现在的和将来的页面元素上。然而,bind()函数只能把事件附加到已经加载过的页面元素上。
也就是说bind()适合页面静态元素而live()适合页面静态和动态元素。
内容总结
以上是互联网集市为您收集整理的ASP.NET jQuery 实例10 动态修改hyperlink的URL值全部内容,希望文章能够帮你解决ASP.NET jQuery 实例10 动态修改hyperlink的URL值所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。