修改JS为
$(document).ready(function(){$("#menu_id ul ul").css("display","block")
$("#menu_id ul ul ul li a").click(function(){
console.log($(this).html())
})
})
$this只是个自定义的变量;$(this)是将当前don对象转换成jquery对象 ;
一般定义jquery变量习惯$开头,提高可读性而已。
$(this)是把DOM对象封装成jquery对象,其相当于一个集合。
用法如下:
<a href="http://IP/q/1010000000125418" target="_blank" data-id="1010000000125418">jQuery</a>
$('a').click(function(){
this.innerHTM==$(this).html()=='jQuery'//三者是一样的.
this.getAttribute('href')==this.href==$(this).attr('href')//三者是一样的
this.getAttribute('target')==this.target==$(this).attr('target')//三者是一样的
this.getAttribute('data-id')==$(this).attr('data-id')//二者是一样的
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)