<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Document</title> <style> div{ width: 100px; height: 100px; } .box1{ background-color: red; } .box2{ background-color: yellow; } </style> <script type="text/javascript" src="jquery.js"></script></head><body> <div class="box1"></div> <div class="box2"></div> <script> $(function(){ (function(){ $('.box1').click(function(){ alert('red'); }) })() (function(){ $('.box2').click(function(){ alert('yellow'); }) })() }) </script></body></html>代碼就是這樣點擊紅色 能正常彈出彈框 下面的報錯 這個錯誤是什么原因?
jquery不能有多個匿名函數自執行?
FFIVE
2018-10-09 09:44:19