jquery 用 find查找一个元素的时候,怎样才能知道找到还是没找到?
find() 方法获得当前元素集合中每个元素的后代
可以判断是否为undefined
$(".comment_list").find(".comment")[0] == undefined
也可以用size()判断有多少个
$(this).closest('.comment').find(".show_remain_reply").size()
也可以用length判断有多少个
$(this).closest('.comment').find(".show_remain_reply").length
如对本文有疑问, 点击进行留言回复!!
荐 微信小程序动态评分展示/五角星展示/半颗星展示/自定义长度展示
深入理解CSS background-blend-mode的作用机制
网友评论