Permudious
New Member
- Dec 28, 2014
- 25
- 1
Goodmorning Guys,
I am developing a webpage which works fine.
Now I would like to create a right click event, I did already some research. but can't find the solution which will fit for me.
When I rightclick on a button I would like to see the name of the button, but when I do this on the second button I still see the name of the first button.
My code:
I am developing a webpage which works fine.
Now I would like to create a right click event, I did already some research. but can't find the solution which will fit for me.
When I rightclick on a button I would like to see the name of the button, but when I do this on the second button I still see the name of the first button.
You must be registered for see images attach
My code:
ASP.net:
<div class="nac">
@foreach(var Person in Model.Persons.Where(x => x.FrstName == "Katherine" || x.FrstName == "Jane" ))
{
string Cardholder = "";
if (Person.MiddleName == "") { Cardholder = Person.LastName + ", " + Person.FrstName; } else if (Person.MiddleName != null) { Cardholder = Person.LastName + " " + Person.MiddleName + ", " + Person.FrstName; } else { Cardholder = Person.LastName + ", " + Person.FrstName; }
<button id="item" class="na">@Cardholder<p class="rmlv">OUT</p></button>
<div id="myDiv" style="display: none;">
<a href="#" class="close" onclick="closeMessage('message-balloon1')">×</a>
<p class="title">Change State</p>
<p class="subtitle">@Cardholder</p>
</div>
}
</div>
JavaScript:
<script>
document.addEventListener('contextmenu', function (e) {
e.preventDefault();
var div = document.getElementById('myDiv');
div.style.left = e.pageX + 'px';
div.style.top = e.pageY + 'px';
div.style.display = 'block';
});
document.addEventListener('click', function () {
var div = document.getElementById('myDiv');
div.style.display = 'none';
});
var closebtns = document.getElementsByClassName("close");
var i;
for (i = 0; i < closebtns.length; i++) {
closebtns[i].addEventListener("click", function () {
this.parentElement.style.display = 'none';
});
}
</script>