javascript - 如何突出显示 HTML 中的当前 id 元素

标签 javascript jquery html css

我想突出显示当前的“#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/

相关文章:

javascript - 当文本较少时,将文本垂直对齐到图像中间

javascript - 将 AJAX 加载程序附加到各个链接上的菜单/导航栏

php - 如何将 JSON 数组传递到 URL?

javascript - 如何检查完整的div是否有效?

html - 为什么 django 在使用 bootstrap 时在页面顶部显示 white lite

javascript - 将行附加到网格

jquery - jQuery 中的 toggleClass 跳过 css 规则

java - 如何为 css、js、jsp 文件提供版本控制

html - 重置 CSS :nth-of-type counter

javascript - ES256 的 JWT 签名要求