jQuery(this) $(this) 两者有什么区别?

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 13:59:32

jQuery(this) $(this) 两者有什么区别?
jQuery(this) $(this) 两者有什么区别?

jQuery(this) $(this) 两者有什么区别?
$这个符号 是jquery的缩写 两者没区别的 都是代表一个jquery对象
$(this)是指当前操作的对象 如下:
$("#btn1").click(function(){
$(this).css("color","#aaa");
})
在这里的$(this) 就是指#btn1

两者一样,代表一个jquery对象

$括号里面div后面怎么有个逗号 这是什么用法 不是很明白 请高手赐教 逗号是搜索多个条件 $('div')搜索div元素 $($(this).parents('div:first')