日期:2014-05-16 浏览次数:20353 次
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> function get_onclick(){ $("li").click(function (e){ var onclick_val= $(e.target).attr("onclick"); alert(onclick_val); }) } $(function(){get_onclick()}); </script> <ul> <li onclick="hello()">hello</li> <li onclick="world()">world</li> </ul>
window.onload = function(){ var lis = document.getElementsByTagName('li'); for (var i in lis) { lis[i].onclick = function() { alert(this.getAttribute('onclick')); }; } };