最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Hierarchical menu nesting problem with jQuery targetting

programmeradmin4浏览0评论

(Wordpress's menu use the form

<li class="menu-item-has-children"> Item
  <ul class="sub-menu">
    <li> Sub Menu Item</li>
    ...
  </ul>
</li>
...

which means that any click event on a sub menu item is also a click on the parent item. ( It also means that any styles like background-color affect also the enclosed children but that's easy to resolve)

I want to target (in this example) $('.sub-menu') without the click event affecting the enclosing .menu-item-has-children so that I can treat a click on the outer 'Item' differently to the inner 'Sub Menu Item'.

So far I have not been able to do this.

发布评论

评论列表(0)

  1. 暂无评论