js常见的var that = this的用法
来源:互联网 发布:mac钥匙串怎么关闭 编辑:程序博客网 时间:2024/05/16 15:05
this是Javascript语言的一个关键字。它代表函数运行时,自动生成的一个内部对象,this代表的是当前对象,只能在函数内部使用
var that=this就是将当前的this对象复制一份到that变量中
$(‘#conten').click(function(){ //this是被点击的#conten var that = this; $(‘.conten').each(function(){ //this是.conten循环中当前的对象 //that仍然是刚才被点击的#conten });});
可以看到,this对象在程序中随时会改变,而var that=this之后,that没改变之前仍然是指向当时的this,这样就不会出现找不到原来的对象
阅读全文
0 0
- js常见的var that = this的用法
- var that = this
- 为什么在js中要写var this =that?
- 【JavaScript】var that = this
- js中var self=this的解释
- js中var self=this的解释
- js中var self=this的解释
- javascript中var that=this
- javascript中var that=this
- javascript中var that=this
- javascript中var that=this
- JavaScript 中的 var that = this
- 为什么要写var that = this;
- Javasript 关于self(that) = this用法的理解
- js this 的用法
- js this的用法
- JS this的用法
- js的this用法
- 简单实用的反编译技巧
- GLSL 内建函数
- TP5 layui 储存type分类ID,记录显示中显示对应的中文名称
- 借助redis主从复制来了解系统的发送和接收缓冲区
- Apache与Tomcat有什么关系和区别
- js常见的var that = this的用法
- 2017年的小总结年初至10月
- (Java)jfinal 实现微信现金红包发送,欢迎各种软件业务订制开发合作
- 使用dom4j读取xml配置文件
- 2万汉字编码大全
- PAT甲级 1024. Palindromic Number (25)
- Git 常用命令
- SpringBootApplication等价于 @Configuration @EnableAutoConfiguration @ComponentScan
- 如何将 eth0 和 wlan0 进行桥接 并且 wlan0 作为 AP 模式 供手机连接(手机静态获取ip)