我想突出显示当前的“#id”片段:
如果 URL 是:http://localhost:4321/store/zapakshop/#943
然后 id=943 应该突出显示..
我已经试过了,但是没有用:
$(document).ready(function () {
$(window.location.hash).effect("highlight", {
color: "#FF0000"
}, 3000);
});
帮我...
最佳答案
Yes it is working but it is changing the color permanently i just want a flash... – user2217267
Snook有一个用 CSS3 做这个的很好的例子。这是一个改编自该页面的工作示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css" media="all">
:target {
-webkit-animation: target-fade 3s 1;
-moz-animation: target-fade 3s 1;
}
@-webkit-keyframes target-fade {
0% { background-color: rgba(0,0,0,.1); }
100% { background-color: rgba(0,0,0,0); }
}
@-moz-keyframes target-fade {
0% { background-color: rgba(0,0,0,.1); }
100% { background-color: rgba(0,0,0,0); }
}
</style>
</head>
<body>
<p>Click the link to <a href="#goal">target the div</a>.
<div id="goal">This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. This is the div. </div>
</body>
</html>
关于javascript - 如何突出显示 HTML 中的当前 id 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16299586/