ASP.NETjQuery实例10动态修改hyperlink的URL值
2023-06-13 09:14:32 时间
1.先准备界面代码:
复制代码代码如下:
<formid="form1"runat="server">
<divalign="left">
<fieldsetstyle="width:300px;height:200px;">
<tablecellpadding="0"cellspacing="0"border="0">
<tr>
<tdstyle="width:10px">
</td>
<td>
<p>
更新网址:</p>
<asp:RadioButtonListID="rblUrl"runat="server">
<asp:ListItemText="新浪"Value="http://www.sina.com.cn"></asp:ListItem>
<asp:ListItemText="百度"Value="http://www.baidu.com"></asp:ListItem>
<asp:ListItemText="网易"Value="http://www.163.com"></asp:ListItem>
</asp:RadioButtonList>
<br/>
<asp:HyperLinkID="hyperLink"runat="server">点击这儿</asp:HyperLink>
</td>
</tr>
</table>
</fieldset>
</div>
</form>
2.RadioButtonList转换成<table/>,其成员转换为<inputtype="radio"/>,下面是实现改变URL值的脚本代码:
<headrunat="server">
<title>Recipe10</title>
<scriptsrc="Scripts/jquery.js"type="text/javascript"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$("input[type=radio]").bind("change",function(){
$("#<%=hyperLink.ClientID%>").attr("href",$(this).val());
});
});
</script>
</head>
3.实现界面效果:
$("input=[type=radio]").live("change",function(){
$("a").attr("href",$(this).val());
});
5.live()和bind()函数的区别:
live()函数可以附加事件到现在的和将来的页面元素上。然而,bind()函数只能把事件附加到已经加载过的页面元素上。
也就是说bind()适合页面静态元素而live()适合页面静态和动态元素。
相关文章
- 【说站】java实例变量是什么?
- SOLIDWORKS 2023新功能|装配体升级!阵列实例 配合错误修复 零件替换功能增强
- 关于单台MongoDB实例开启Oplog的过程详解
- Oracle查询优化日期运算实例详解
- 数据ASP 实现MySQL数据库更新(asp更新mysql)
- ASP网页MySQL注入及防御研究(asp页面mysql注入)
- 如何使用ASP添加MySQL引用(asp添加mysql引用)
- 基于ASP技术连接MySQL数据库(asp支持mysql)
- ASP 操作简单,快速修改MySQL数据库(asp修改mysql)
- JavaScriptdelete操作符应用实例
- asp.net(C#)动态添加非ASP的标准html控件(如添加Script标签)
- ASP操作XML文件的完整实例代码
- 解析二进制流接口应用实例pack、unpack、ord函数使用方法
- file_get_contents("php://input","r")实例介绍
- 解析phpmysql事务处理回滚操作(附实例)
- 解读ASP.NET密码强度验证代码实例分享
- ASP.NETMVC中的视图生成实例分析
- js对象继承之原型链继承实例
- PHP针对JSON操作实例分析
- Python发送Email方法实例
- PHP中feof()函数实例测试
- Python实现备份文件实例