Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery-按css类选择_Jquery_Css - Fatal编程技术网

jquery-按css类选择

jquery-按css类选择,jquery,css,Jquery,Css,网络新手 我想知道用户是否用css点击了某个类的div 我的类html元素如下 <div class="icon arrowIcon arrowLight tagIcon"></div> 以及功能 ($(event.target).find('.tagIcon').length > 0) 返回false 有什么想法吗 find()在被调用的元素中查找匹配的元素。元素本身是否与选择器匹配并不重要 将支票更改为: ($(event.target).is('.tagI

网络新手

我想知道用户是否用css点击了某个类的div

我的类html元素如下

<div class="icon arrowIcon arrowLight tagIcon"></div>
以及功能

($(event.target).find('.tagIcon').length > 0)
返回false

有什么想法吗

find()
在被调用的元素中查找匹配的元素。元素本身是否与选择器匹配并不重要

将支票更改为:

($(event.target).is('.tagIcon'))

find
搜索子项。您应该检查元素是否具有所需的类:

$(event.target).hasClass("tagIcon")
$(event.target).hasClass("tagIcon")