Check if multiple elements with same class exist
This question already has an answer here:
尝试使用length属性来完成您的任务, 
if($('.panel').length > 1) {
  console.log('yes, more than one element exist')
}
if ( $('.panel').length >= 2 ) {
    console.log('exists')
}
这应该工作
只需使用length属性;)
if ($('.panel').length > 0) {
  // your code
}
                        链接地址: http://www.djcxy.com/p/14678.html
                        上一篇: 如何知道使用jquery是否存在具有特定id的div
下一篇: 检查是否存在具有相同类的多个元素
