<div class="diskmain"> <ul id="folder"> <li><span class='documents'><a href='javascript:void(0)' id='1' onclick='getid(this);'>分类A</a></span></li> <li><span class='lists'><a href='javascript:void(0)' id='2' onclick='getid(this);'>分类B</a></span></li> <li><span class='pictures'><a href='javascript:void(0)' id='3' onclick='getid(this);'>分类C</a></span></li> <li><span class='share'><a href='javascript:void(0)' id='4' onclick='getid(this);'>分类D</a></span></li> </ul> </div> <script> function getid(a){ alert(a.id) }; </script>
转载自:http://blog.csdn.net/asdf1213321/article/details/8752061