running a code before showing context menu during customized right click in jquery
-
12-09-2019 - |
Question
I used context menu plugin and was able to make if functional on the page I currently developing. At right click, I want to run a code (such as to highlight a selected row or column) before showing the context menu. Where can I insert the code. I used the plugin on this link. http://www.trendskitchens.co.nz/jquery/contextmenu/
My html:
<table>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<table>
My js (context menu)
$("table tr td").contextMenu('myMenu',{
onContextMenu: function(e){
// I want to process the selected 'td' or 'tr' here... ex. highlight it
}
});
OTHER TIPS
You can use the following code to highlight the parent row
$("table tr td").contextMenu('myMenu',{
onContextMenu: function(e){
var parent=$(e.currentTarget).parent();
parent.addClass('SelectedRowColor');
}
where SelectedRowColor row is the css class name . hope that will help.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow