gpt4 book ai didi

jquery - 如何检测 find() 函数没有找到任何内容?

转载 作者:行者123 更新时间:2023-12-01 06:27:26 25 4
gpt4 key购买 nike

我想使用find函数来查找元素,但是我如何检测没有找到任何东西?

这是我的代码,无法正常工作并且始终返回true:

if ($(this).find('img'))
return true;

最佳答案

使用.length

if ($(this).find('img').length)
return true;

关于jquery - 如何检测 find() 函数没有找到任何内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17574417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com