首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

jquery 批量批改超链接属性

2012-11-18 
jquery 批量修改超链接属性这个例子修改的是超级链接地址[code]?xml version1.0 encodingUTF-8 ?

jquery 批量修改超链接属性

这个例子修改的是超级链接地址[code]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="Tianfan" />
<script type="text/javascript" src="lib/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#testbutton").click(function(){
? ? ? ? ? ? ? ? $("#menu>a").each(function(){
? ? ? ? ? ? ? ? ? ? ? ? var reg=/\&b=\d+/;
? ? ? ? ? ? ? ? ? ? ? ? this.href=this.href.replace(reg,"&b=6666");
? ? ? ? ? ? ? ? ? ? ? ? alert(this.href);
? ? ? ? ? ? ? ? }
);
? ? ? ? });
});
</script>
<title>Insert title here</title>
</head>
<body>
<div id="menu">
<a href="/abc.php?a=123&b=40000">测试内容</a><br/>
<a href="/def.php?a=222&b=40000">测试二</a><br />
<a href="/fff.php?a=333&b=40000">测试三</a><br />
</div>
<a href=="/666.php?a=444&b=40000">这儿的链接不替换</a>
<button id="testbutton">测试</button>
</body>
</html>
[/code]

?

?

?

下面内容用来使页面中超链接里面的关键字变色:

<script>
? ??$(function(){
? ??? $(".c1-body a").each(function(){
??????????????? var reg=/${searchKey}/;
??????????????? $(this).html($(this).html().replace(reg,"<font color='red'>${searchKey}</font>"));
???????????? });
? ??});
? ?</script>

热点排行