I have two columns, and two inputs, made to create new content that will be placed in any of those columns.
One input is to enter the content of the div (and assign the class="item"), the second input is for entering the class for that content (for styling).
So, I want to be able to open a custom context menu when I right-click on any of the items I have created. (Bit of a problem to me). With jQuery.
Can you help come through this, please.
html
<div id="ctxtmen" class="invisible">
<ul>
<li>Edit</li>
</ul>
</div>
And the jQuery.js
$(".item").mousedown(function(e){
if( e.which == 3 ) {
$("#ctxtmen").removeClass("invisible").css({top: event.pageY + "px", left: event.pageX + "px"});
}
$(document).click(function(){
$("#ctxtmen").addClass("invisible");
if( e.which == 2 ){
$("#ctxtmen").addClass("invisible");
}
});
$(document).bind("contextmenu", function(x){
if (!$("#ctxtmen").hasClass("invisible")) {
x.preventDefault();
}
});
});
Check out the: jsFiddle