jQuery检查元素是否具有元素 [英] jquery Checking to see if element has element
本文介绍了jQuery检查元素是否具有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jquery 1.3,并试图复制1.4.has功能.
I'm using jquery 1.3 and is trying to duplicate the 1.4 .has functionality.
我需要检查.page元素是否包含图像,如果没有,请附加图像.
I need to check if the .page element contains the image, and if it doesn't, append it.
是这样的吗?
var imageid = thirdimage;
if ($('#page:has(#'+imageid+')') === undefined) {
$('#page').append($('#'+imageid));
}
谢谢.
推荐答案
if( $('#page').find('#'+imageid).length )
// I has the image! :P
这篇关于jQuery检查元素是否具有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文