How do I get the id of type "invokedOn" by right click event using Bootstrap ContextMenu?

I am using Bootstrap 3.0 ContextMenu. here's a link

I need to know how can I get the id or data-id of the clicked element. I am trying many tricks but I cannot get the id of the clicked element? For example, when I clicked on the line "Jacob", I got "Jacob" after clicking. I also need this
<td data-id="user-3"> <a data-id="user-3">Jacob<a/> <td/>

"Data-Id" string ?

I tried var $selectedFileId = $(this).closest('a').html();



source to share

2 answers

Use this code to get id of clicked element

jQuery(document).on('click', function(e){




I am getting id by small additions in contextMenu handler, Changes

// click handler for context menu
function ContextMenuClickHandler() {
     .on('click', function (e) {

       var $invokedOn = $(this).data("invokedOn");
       var $selectedMenu = $(;
       // My Changes
       var $selectedFileId = $(this).data("invokedOn").find('.yourClass').attr('id');$(this), $invokedOn, $selectedMenu, $selectedFileId);




All Articles