

<!DOCTYPE html><html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<script src="
<script type="text/javascript">$(document).ready(function () {
$("#check").click(function () { if ($(".mytest").length > 0) {
alert("此元素存在");
}
})
})</script><body><ul>
<li>太阳出来了</li>
<li>蚂蚁部落</li>
<li class="mytest">p+CSS教程</li> </ul><button id="check">点击检测</button></body></html>如果集合中元素的数量大于零,那么元素存在,否则指定元素不存在。
