选中后锚定链接激活Probelm [英] Anchor link active Probelm after selected
本文介绍了选中后锚定链接激活Probelm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已使用这些突出显示所选链接,但点击该链接后链接背景颜色已停用,请帮助解决此问题
这是我的代码
JS
I have used these for highlighted the selected link but after clicking that link the link background color deactivated so please help how to resolve this
this is my code
JS
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<script type="text/javascript">
$(document).ready(function () {
$('.header a').click(function () {
$('.header').removeClass('active');
$(this).parent().addClass('active');
});
});
</script>
CSS
CSS
<style type="text/css">
.header {
font-size: 16px;
width:120px;
}
.active {
background-color: red;
}
.active a {
color:yellow;
}
</style>
Asp.net
Asp.net
<div class="header">
<ul>
<li class="header">
<a href="#">Home</a>
</li>
<li class="header">
<a href="#">about</a>
</li>
<li class="header">
<a href="#">contact</a>
</li>
</div>
推荐答案
(文件).ready(function(){
(document).ready(function () {
('。header a')。click(function(){
('.header a').click(function () {
('。header')。removeClass('active');
('.header').removeClass('active');
这篇关于选中后锚定链接激活Probelm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文