【发布时间】:2012-11-04 00:49:49
【问题描述】:
每次我尝试将以下代码添加到我的网站时,页面上的每个 <a href> 链接都会打开。如何在不打开每个<a href> 链接的情况下使此代码正常工作,而不是使用单击功能,我可以使用按钮及其 id 代替吗?
<!DOCTYPE html>
<html>
<head>
<style>
p.one { position:relative; width:400px; height:90px; }
div.two { position:absolute; width:400px; height:65px;
font-size:36px; text-align:center;
color:yellow; background:red;
padding-top:25px;
top:0; left:0; display:none; }
span.three { display:none; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p class="one">
Let it be known that the party of the first part
and the party of the second part are henceforth
and hereto directed to assess the allegations
for factual correctness... (<a href="#">click!</a>)
<div class="two"><span class="three">Click here to continue...</span></div>
</p>
<script>
$("a").click(function () {
$("div").fadeIn(3000, function () {
$("span").fadeIn(100);
});
return false;
});
</script>
</body>
</html>
【问题讨论】:
-
你应该先学习 html 和 css 选择器
-
无法理解问题所在。请改写你的问题。
-
你为什么不尝试你正在做的事情?你有代码,发布问题和格式化代码比尝试使用你提到的按钮和 ID 更容易吗?
-
这里显示的代码可以正常工作jsfiddle.net/rZKP3
标签: jquery function tags click href