可能重复:
How to check if jQuery object exist in array?的jquery inArray()
有任何方法,以确定是否一个DOM元素是在DOM元素的数组?
即
$(".container img").each(function(){
views.push($(this).clone());
});
创建克隆图像元素的阵列。我现在想检查一个新的图像元素是否在该数组中?
感谢
可能重复:
How to check if jQuery object exist in array?的jquery inArray()
有任何方法,以确定是否一个DOM元素是在DOM元素的数组?
即
$(".container img").each(function(){
views.push($(this).clone());
});
创建克隆图像元素的阵列。我现在想检查一个新的图像元素是否在该数组中?
感谢
$(".container img").each(function(){
if(jQuery.inArray($(this), views) === -1)
{
views.push($(this).clone());
}
});
'views.indexOf(yourImage)!== -1' –
你不喜欢['inArray()'](http://api.jquery.com/ jQuery.inArray /)?你已经写在标题... – Christoph