开发者

Removing href from dynamic item?

开发者 https://www.devze.com 2023-01-18 15:12 出处:网络
I\'m trying to remove the link href from an unordered list item. The menu has been created by wordpress and I\'m trying to remove the link from the first item, so that when开发者_如何学Go I user roll

I'm trying to remove the link href from an unordered list item.

The menu has been created by wordpress and I'm trying to remove the link from the first item, so that when开发者_如何学Go I user rolls over the item the menu still drops down but the very first item (the one that triggers the drop down) isn't clickable.

Currently I just have href="#" in place but I'd like to remove the link altogether.

How can I go about stripping out the href element?


After creating the menu item place holder remove the # from the URL field to create the non clickable dropdown place holder.

This is possible by adding a custom link to the menu assigning it any url (for this example I just added #) then click add to menu. Once it's on the menu open it and remove the url you assigned and save. If you don't put the url initially WordPress won't let you add it to the menu. On your pages you will be able to hover over it and the drop down children will appear but you wont be able to click on the parent "place holder".

Removing href from dynamic item?

Removing href from dynamic item?

Note: This answer is from the same question on WordPress Answers


<a href="http://example.com" onclick="javascript:return false;">Click me</a>


I am supposing the menu you are talking abou is an automatic one.

I would use jQuery to prevent the default action of the link.

<script>
$("menu-item-123").click(function(event) {
  event.preventDefault();
});
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消