两个元素,相同事件逻辑,互相赋值
作者:互联网
<!DOCTYPE html> <html> <head> <style> </style> </head> <body> <div id="d1">a123</div> <div id="d2"> b 123 0 </div> <script> let d1 = document.querySelector('#d1'); let d2 = document.querySelector('#d2'); d1.onclick = function(){ alert(5545454544554); } d2.onclick = function(){ d1.onclick(); } </script> </body> </html>
标签:function,逻辑,document,元素,let,onclick,赋值,d2,d1 来源: https://www.cnblogs.com/wgqy/p/16320264.html