I am new to jQuery and i have a problem about getting the value that i need from a variable. More specific I have this list on html file.
<ul id="menu">
<li class="mainmenu" id="newsarticles"><a href="#">News & articles</a>
<ul id="newsarticles">
<li class="submenu" id="news"> <a href="#">News</a>
</li>
<li class="submenu" id="articles"> <a href="#">Articles</a>
</li>
</ul>
<li class="mainmenu" id="contactus"><a href="#">Contact Us</a>
</li>
</ul>
Now i want to use the same function both to mainmenu and submenu.
$("#menu li").click(Menu_function);
My problem is that when i click on submenu, variable $(this) has two values. one for the li inside the submenu and one for the li of mainmenu.
now i would like to do something like this in my function:
var currentId = $(this).attr('id');
How could I get only one value?
Any help appreciated.