认真仔细的看了一边CSS结构,就是前端经常用的json对象,只是一直没注意,直到javascript函数调用CSS样式的时候才发现,做个记号吧!
.menuBox { display: inline-block; position: absolute; border: 1px solid #aaa; background-color: #fff; font-size: 12px; width: 120px; text-align: center; }
var showMenu = function (event, item) { var menu = document.getElementById("menuBox"); menu.style.display = "block"; menu.style.left = event.x + "px"; menu.style.top = event.y + "px"; menu.getElementsByClassName("menuTitle")[0].innerHTML = item.data.name; }
Done!