gpt4 book ai didi

查询 : Menu active when click

转载 作者:太空宇宙 更新时间:2023-11-04 15:38:53 26 4
gpt4 key购买 nike

我创建菜单:

<ul id="menu">
<li>
<a href="#" onclick="load(1);return false;"> Team Install</a>
</li>
<li>
<a href="#" onclick="load(2);return false;"> PC and Laptop Service</a>
</li>
<li>
<a href="#" onclick="load(3);return false;"> Web Design and Internet Services</a>
</li>
<li>
<a href="#" onclick="load(4);return false;"> Software and Database Dev.</a>
</li>
</ul>
<div id="LoadMe"></div>

这就是我在 jquery 中所做的:

<script type="text/javascript">

$(document).ready(function () {
$("#LoadMe").load('/Service2.html');
$('#menu a[href="' + url + '"]').addClass('selectedcategoryServices');
});

function load(num) {
$("#LoadMe").load('/Service' + num + '.html');
}

</script>

但是当我准备好点击菜单时,菜单没有selectedcategoryServices,谁能告诉我该怎么做?

最佳答案

这样试试

$("a").click(function(){
$("a.selectedcategoryServices").removeClass("selectedcategoryServices");
$(this).addClass('selectedcategoryServices');

});

检查这个demo

关于查询 : Menu active when click,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12435916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com