target 事件屬性
定義和用法
target 事件屬性可返回事件的目標節點(觸發該事件的節點),如生成事件的元素、文檔或窗口。
語法
event.target
定義結束事件JavaScript
JS修改內容提示框樣式-https://help.finereport.com/doc-view-2518.html
var oldTitle = null; $('td').bind('mouseover mouseout mousemove', function(event) { var left = event.pageX; var top = event.pageY; var ele = event.target; var title = ele.title; var type = event.originalEvent.type; if (type == 'mouseover') { oldTitle = title; ele.title = ''; console.log(title); if (title.length != 0) { var showEle = $('<div></div>', { text: title, class: 'showTitleBox' }).css({ position: 'absolute', top: top + 10, left: left, border: '1px solid #00cccc', // 邊框 borderRadius: '5px', // 邊框圓角 background: "#00cccc", // 背景色 fontFamily: 'SimHei', // 字體 fontSize: '15px' // 字體大小 }) showEle.appendTo('body'); } } else if (type == 'mouseout') { ele.title = oldTitle; $('.showTitleBox').remove(); } else if (type == 'mousemove') { $('.showTitleBox').css({ top: top + 10, left: left }) } })
其中
border: '1px solid #00cccc', // 邊框
borderRadius: '5px', // 邊框圓角
background: "#00cccc", // 背景色
fontFamily: 'SimHei', // 字體
fontSize: '15px' // 字體大小