How to get the clicked menu details

Total Post:108

 1328  View(s)
Rate this:

i have jquery menu like

<ul id="fileMenu">
<ul  id="editMenu">

i got the way to get click event on child menu items like

  $('#fileMenu').on('click', 'li', function () {
            alert("Hello"); // Or make($(this)); if you still want that extra function

But, how to find out the particular menu option, i.e user clicked on Open, Exit, Edit, delete etc...

  1. Post:412

    Re: How to get the clicked menu details

    Use clicked element context this to create jquery selector along with .text() to get the text in it.

    You will also need to add other parent ul selector(like #editMenu) to target their elements as well :

    $('#fileMenu,#editMenu').on('click', 'li', function () {
            var currenttext=$(this).text();
            alert(currenttext);         if(currenttext=="Add"){
                //perform Add
            }else if(currenttext=="Delete"){
                //perform delete
                //perform edit

      Modified On Apr-08-2018 11:35:35 PM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.