Get ID of a clicked parent ID
- by Yan Cheng CHEOK
I try using evt.parent.attr("id") inside jsddm_close, but it doesn't work.
<script type="text/javascript">
var ddmenuitem = 0;
function jsddm_open()
{
// When "help-menu" being click, I will toggle drop down menu.
ddmenuitem = $(this).find('ul').eq(0).toggle();
}
function jsddm_close(evt)
{
// When everywhere in the document except "help-menu" being clicked, I will close the drop down menu.
// How I can check everywhere in the document except "help-menu"?
if (ddmenuitem) ddmenuitem.hide();
}
$(document).ready(function()
{
$('#jsddm > li').bind('click', jsddm_open);
$(this).bind('click', jsddm_close);
});
</script>
<ul id="jsddm">
<li><a href="#">Home</a></li>
<li><a href="#" id="help-menu"><u>Help</u><small>xx</small></a>
<ul>
<li><a href="#">menu item 1</a></li>
<li><a href="#">menu item 2</a></li>
</ul>
</li>
</ul>