- JScript code
<head> <style type="text/css"> </style> <script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script> $(function() { alert($("li:first").closest(["ul", "body"])); }) </script> </head> <body> <ul><li></li><li></li></ul> </body>
- JScript code
<head> <style type="text/css"> </style> <script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script> $(function() { alert($("li:first").closest(["ul", "body"]).size()); }) </script> </head> <body> <ul><li></li><li></li></ul> </body>
第一段代码弹出是Object,第二段代码就报错,说没这个函数。
难道closest()方法返回的不是Jquery包装集吗?不能使用.size()??
谢谢!
------解决方案--------------------
alert($("li:first").closest("ul","body").size());
没有中括号