如何點(diǎn)擊后只出現(xiàn)連接而不跳轉(zhuǎn)?
想寫成點(diǎn)擊“點(diǎn)我就變”后只出現(xiàn)下一行的網(wǎng)址,并不跳轉(zhuǎn)地址,要怎樣改呢?
<!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()方法設(shè)置元素屬性</h3>
? ? ? ? <a id="a1" onclick="a1()">點(diǎn)我就變</a>
? ? ? ? <div>我改變后的地址是:<span id="tip"></span></div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? $("#a1").click(
? ? ? ? ? ? function a1(){
? ? ? ? ? ? $("#a1").attr("href","idcbgp.cn");
? ? ? ? ? ? var $url = $("#a1").attr("href");
? ? ? ? ? ? $("#tip").html($url);
? ? ? ? ? ? }
? ? ? ? )
? ? ? ? </script>
? ? </body>
</html>
2016-05-11