為什么跳轉的不是我指定頁面?還是原來的屬性值?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
? ? <head>
? ? ? ? <title>操作元素屬性</title>
? ? ? ? <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
? ? ? ? <link href="style.css" rel="stylesheet" type="text/css" />
? ? </head>
? ??
? ? <body>
? ? ? ? <h3>attr()方法設置元素屬性</h3>
? ? ? ? <a id="a1">點我就變</a>
? ? ? ? <div>我改變后的地址是:<span id="tip"></span></div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $("#a1").attr("href" , "www.baidu.com");
? ? ? ? ? ? var $url = $("#a1").attr("href");
? ? ? ? ? ? $("#tip").html($url);
? ? ? ? </script>
? ? </body>
</html>
2016-06-26
"www.baidu.com"改成"http://www.baidu.com"就行了