如何点击后只出现连接而不跳转?
想写成点击“点我就变”后只出现下一行的网址,并不跳转地址,要怎样改呢?
<!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 href="http://127.0.0.1" id="a1" onclick="a1()">点我就变</a>
<div>我改变后的地址是:<span id="tip"></span></div>
<script type="text/javascript">
$("#a1").click(
function a1(){
$("#a1").attr("href","www.imooc.com");
var $url = $("#a1").attr("href");
$("#tip").html($url);
}
)
</script>
</body>
</html>