Reputation: 851
I am using the below to open and close a menu onclick - but most importantly, to change the link text from 'Menu' to 'Close'.
Is there a way to change the 'Close' link text back to 'Menu' with out clicking the link, but by clicking any where on the page?
<span class="menu-link">Menu</span>
<span class="menu-link" style="display:none">Close</span>
<script type="text/javascript">
jQuery(function() {
jQuery(".menu-link").click(function()
{
jQuery(".menu-link").toggle();
});
});
</script>
Thanks
Upvotes: 0
Views: 7811
Reputation: 411
Add a click event to the body tag so that when you click elsewhere on the page, it will toggle it or you could have it only work to change it back to menu.
jQuery("body").click(function () {
jQuery(".menu-link").toggle();
});
Upvotes: 2