Add then remove Node

My code:
mouseEnter: function (e, node) {
addAndRemoveNode(node, 1)
mouseLeave: function (e, node) {
addAndRemoveNode(node, 2)

function addAndRemoveNode(node, type) {
if (type == 1) {
var node1 = new go.Node(go.Panel.Auto);
node1.position = new go.Point(node.$f.x + 30, node.$f.y + 30);
var textblock = new go.TextBlock();
textblock.text = “hello!”;
textblock.margin = 5;
else myDiagram.remove();

question: Event mouseEnter add a Node then Event mouseLeave i want remove it but not working. Help me!

You need to find the Node that you added so that you can call Diagram.remove on it.

Only use documented properties and methods. “$f” is not a documented property of the Node class.

What are you really trying to accomplish? Perhaps you want to use a tooltip instead?

Thanks you sir!! :D