views:

28

answers:

3

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 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?

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

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".

alt text alt text

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

Chris_O
Thanks I was unaware that wordpress would remove the href on its own.
Adam
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>
Beto Frega
I missed the hash and the anchor tag. It is supposed to go something like "#menu-item-123 a".
Beto Frega