如何在我的代码中使用 onclick
事件添加或删除节点和链接?
使用方法:右键单击任何节点,然后单击“delete”以删除所有节点但不删除链接。
但我只想删除一个节点及其链接,即单击删除的节点。
//right click menu items
$('g.node').contextMenu('cntxtMenu',
{
itemStyle:
{
fontFamily : 'Arial',
fontSize: '13px'
},
bindings:
{
'open': function(t) {
alert(t.__data__.name);
},
'email': function(t) {
alert('Trigger was '+t.__data__.name+'\nAction was Email');
},
'save': function(t) {
alert('Trigger was '+t.__data__.name+'\nAction was Save');
},
'delete': function(t) {
$('g.node').remove();
//alert('Trigger was '+t.__data__.name+'\nAction was Delete');
}
}
});
$('g.node').remove();
替换为$(t).remove();
。 - Arun P Johny