【发布时间】:2010-01-20 01:13:12
【问题描述】:
我正在尝试使用 jQuery 获取 href 值:
<html>
<head>
<title>Jquery Test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function(event) {
alert("As you can see, the link no longer took you to jquery.com");
var href = $('a').attr('href');
alert(href);
event.preventDefault();
});
});
</script>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
</body>
</html>
但它不起作用。为什么?
【问题讨论】:
-
想告诉我们究竟是什么不起作用?警报是空的吗?你有没有收到 2 个警报?有js错误吗?它对我有用...
-
UPSs ...,对不起。问题是清除缓存
标签: javascript jquery