I have disabled context menu(mouse right click) for Document. $(document).bind('contextmenu',function(){return false;}); Now I want to enable context menu for certain input. $('#nickname').bind('contextmenu', function (){return true;}); But it is not working. Any ideas?
0
votes
1 Answers
1
votes
You could return true/false from document context menu handler depending on the element you clicked on. See .target
property of event
.
$(document).bind('contextmenu',function(event){
if (event.target == document.querySelector("#nickname")) {
return true;
} else {
return false;
}
});
See full example: https://codepen.io/anon/pen/gqmXZJ?editors=1010
Try to console.log(event)
when not sure what to do with events, there are a lot of helpful properties there.