jQuery里面用this和用$(this)有什么区别?
2016-09-09 14:39
489 查看
转自:http://zhidao.baidu.com/question/258783817.html
this 当前对象。
$(this) jquery对象
前则不能直接访问jquery方法。
$(function(){
$('button').click(function(){
//$(this)表示当前对象,在这里指的是button按钮
$(this).closest('tr').remove();
//或者:
$(this).parent().parent().remove();
//或者:
$(this).parents('tr').remove();
})
})
this表示的是javascript提供的当前对象 $(this)表示的是用jquery封装候的当前对象 this对象可以直接用this.style修改样式 $(this)可以使用jquery提供的方法访问样式 比如this.style.display="none"在jquery中可以用$(this).css("display","none")实现
this 当前对象。
$(this) jquery对象
前则不能直接访问jquery方法。
$(function(){
$('button').click(function(){
//$(this)表示当前对象,在这里指的是button按钮
$(this).closest('tr').remove();
//或者:
$(this).parent().parent().remove();
//或者:
$(this).parents('tr').remove();
})
})
相关文章推荐
- jquery里面的$(this)和this都什么时候用,有什么区别
- jquery里面的$(this)和this都什么时候用,有什么区别
- jquery里面的$(this)和this都什么时候用,有什么区别
- jquery里面的$(this)和this都什么时候用,有什么区别
- jquery里面的$(this)和this都什么时候用,有什么区别
- jquery里面.length和.size()有什么区别(转)
- jquery里面.length和.size() index()有什么区别
- jquery里面的$(this) 和this区别
- jquery里面.length和.size()有什么区别
- jquery里面.length和.size()有什么区别
- Jquery里面的$(this)和this的区别
- 多线程里面this.getName()和currentThread.getName()有什么区别
- jquery里面.length和.size()有什么区别
- JQuery -- this 和 $(this) 的区别
- Page.ClientScript.RegisterStartupScript(this.GetType(), "","")引号里面具体代表什么?
- JQuery 下jquery-1.4.2.js和jquery-1.4.2.min.js这两个文件有什么区别 转
- JQuery this 和 $(this) 的区别
- jquery里面 text()和html()的区别
- jquery中this与$(this)的用法区别.