// $(".test1").click(function (){
// test($(this));
// });
// function test ($(this)){
// alert($(this).text());
// }
$(".test1").click(function (){
var $this = $(this);
test($this);
});
function test ($this){
alert($this.text());
}
很久以前就在想这个问题了,不过自己解决不了,就是直接传$(this),chrome会提示函数声明第一行有报错,实参有下划的波浪线。一直都是var obj=$(this)或者$this=$(this),这样才能传,为啥子呢
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
因为
$(this)不是合法的变量名,变量名不能包含()。语法不支持吧
亲测,可以