我有数据库记录列表,我希望每条记录都有命令(如:更新,删除,清除等) 我用ContextMenu.js v 1.2.2 这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src='js/jquery-1.11.1.min.js' type='text/javascript'></script>
<script src='js/contextMenu.min.js' type='text/javascript'></script>
<link rel='stylesheet' type='text/css' href='css/contextMenu.css'>
<script type="text/javascript">
function myDelete(ID){
// do something with ID
}
function myUpdate(ID){
// do something with ID
}
jQuery(document).ready(function($) {
var menu = [{
name: 'delete', img: 'images/delete.png', title: 'Delete Button', disable: 'false',
fun: function () {
alert('i am delete button')
}
},{
name: 'note', img: 'images/update.png', title: 'note button', disable: 'false',
fun: function () {
alert('i am note button')
}
}];
$('.testMenu').contextMenu(menu);
});
</script>
</head>
<body>
<table class="tablesorter" id="tabel-rekap">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<th>Name 1</th>
<th><div class="testMenu"><img src="images/someimages.png" /></div></th>
</tr>
<tr>
<th>2</th>
<th>Name 2</th>
<th><div class="testMenu"><img src="images/someimages.png" /></div></th>
</tr>
<tr>
<th>3</th>
<th>Name 3</th>
<th><div class="testMenu"><img src="images/someimages.png" /></div></th>
</tr>
<tr>
<th>4</th>
<th>Name 4</th>
<th><div class="testMenu"><img src="images/someimages.png" /></div></th>
</tr>
</tbody>
</table>
</body>
</html>
问题是如何将 ID 参数传递给我的函数(删除,更新等)?