@Ejay如果我在此链接的某些子链接中单击,请帮助我设置打开主链接。
此处:设置为 active单击后的手风琴菜单
我进行了一些修改,例如:
< script type = text / javascript> $ {document).ready(function(){ var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/' )+ 1); var url = sPage.split('?')[0]; $('dd')。filter(function(){ return $('a [href ='+ url +']',$(this))。length == 0 })。hide(); $('dt a.submenu')。click(function(){ $( dd:visible)。slideUp( slow); $(this).parent()。next ('dd')。slideDown( slow); 返回false; }); }); < / script>该脚本仅在我的链接为
< a href = test.asp> TESTE< / a>如果我的链接是这样的:< a href = test。 asp?category = BLABLABLA> BLABLABLA< / a> 这不起作用。
出什么问题了
可以在此处部分查看菜单: alsite .br / saks_div /
解决方案如果
var sPath = window.location.pathname;适用于类似 abc.asp 的URL以下应与具有查询字符串的URL一起使用,例如 produtos_categoria.asp?categoria = something
var sPath = window.location.pathname + window.location.search;
@Ejay Help me to set "opened" the main link if i click iin some sublinks of this...
here: Set "active" accordion menu after click
i make some modifications like:
<script type="text/javascript"> $(document).ready(function(){ var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); var url = sPage.split('?')[0]; $('dd').filter(function () { return $('a[href="' + url + '"]', $(this)).length == 0 }).hide(); $('dt a.submenu').click(function () { $("dd:visible").slideUp("slow"); $(this).parent().next('dd').slideDown("slow"); return false; }); }); </script>This script only works if my link is
<a href="test.asp">TESTE</a>if my link is that way: <a href="test.asp?category=BLABLABLA">BLABLABLA</a> this don't work..
what is wrong
Can see the menu working partly here: alsite.br/saks_div/
解决方案if
var sPath = window.location.pathname;works for URL's like abc.asp then following should work with URL's having a query string, e.g., produtos_categoria.asp?categoria=something
var sPath = window.location.pathname+window.location.search;
更多推荐
Active Accordeon菜单不适用于带有查询字符串的子链接
发布评论