var p =document.getElementsByTagName("p")[0]; p.onclick= function(){ alert("aa") }
<p>hahah</p>
p{ color:red; }