Well, I'm trying to build a custom context menu that will work inside a register table. The problem is that I need to get the ID that is inside each line () and call it in the menu link (Edit.php? Id =).
Follow my code so you can see how it is getting.
window.addEventListener('contextmenu', function (e) {
$('.rightclickmenu').css({
"margin-left": e.clientX,
"margin-top": e.clientY
}).show();
e.preventDefault();
window.addEventListener('click', function () {
$('.rightclickmenu').hide();
});
});
<style>
.rightclickmenu {
border: 1px solid #000;
position:absolute;
z-index:1;
font: 11px sans-serif;
display:none;
}
#rightclickobject {
padding: 10px;
width: 100px;
border-bottom: 1px solid #eee;
cursor:pointer;
}
#rightclickobject:hover {
background:#eee;
}
</style>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script><tablewidth="100%" border="1">
<tr>
<td id='1'>ID:1</td>
<td>Nome</td>
<td>Idade</td>
</tr>
<tr>
<td id='2'>ID:2</td>
<td>Nome</td>
<td>Idade</td>
</tr>
</table>
<div class="rightclickmenu">
<div id="rightclickobject" onclick="window.open('Editar.php?id=')">Editar</div>
<div id="rightclickobject" onclick="window.open('Apagar.php?id=')">Apagar</div>
</div>
Thanks for the help.