<div id="divTest"> Test </div> <br /> <hr /> <div id="divTest2" onclick="div2Click();"> Test2 </div> </form> </body> </html> <script type="text/javascript"> function div2Click() { $(this).divClick(); } (function ($) { $.fn.divClick = function () { alert("Test2"); }; $("#divTest").click(function () { alert("Test"); }); })(jQuery); </script>
原文:http://www.cnblogs.com/myblogslh/p/4539564.html