1 回答

TA貢獻2016條經驗 獲得超9個贊
用event.target不可以么?
補充:
我自己做了測試:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
border:1px solid red;
width:400px;
height:400px;
}</style>
</head>
<body>
<div contenteditable="true">
zinc <font size="3" data="font">haha</font><br/>
啦啦啦
</div>
</body>
<script>
window.onload = function() {
document.onclick = function (e) {
console.log(e.target);
if(e.target.getAttribute("data") == 'font') {
e.target.style.color = 'blue';
}
}
}
</script>
</html>
這個可以直接跑,當你鼠標點擊font的時候,font變藍了
添加回答
舉報