Reputation: 253
http://readysalteddev.co.uk/hr/
I'm working on a website with a tray, which hides children menu items under the main item.
I have a .click(function())
which is not recognising the div being clicked. I've tried z-index changes but to no avail. I changed the div to a different div in the tray which worked, so I don't know what's gone wrong.
<li class="menu-item-has-children">
is the click and I'm trying to get the sub-menu in it's parent folder to toggle.
$(document).ready(function()
{
$(".menu-child-arrow").click(function(){
$(this).parent('.menu-item-has-children').toggle();
$(this).toggle();
$(this).parent('.menu-item-has-children').find('>.sub-menu').toggle();
});
});
I've put multiple things in there just as tests, to see if I had incorrectly written the code.
EDIT
For my own sanity when returning to this question, the answer was finally found in a long stream of comments which has been removed so, the accepted answer below was not what fixed this issue, but the guy who gave it did give the right answer. So, what 'fixed' this was:
I had to remove the above code from the gathered source and insert it into the footer separately to allow it to work
If I ever recode it or figure out how what was the deal, I'll return. Otherwise hopefully this helps anyone else.
Upvotes: 0
Views: 43
Reputation: 357
http://jsfiddle.net/Benjih/n1pgoa3m/
You are using .find()
instead of the .children()
I hope this is what you're after! :)
Upvotes: 1