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变蓝了
添加回答
举报