星空网 > 软件开发 > Java

js this的使用举例

js this的使用举例  

<script type="text/javascript">  function test(obj){    obj.style.width= obj.offsetWidth *1.5+"px";    // offsetWidth 表示元素的宽  有了this,不需要document.getElementById();       }</script><div style=" border:1px solid #ccc; width: 300px; height: 200px;"   onClick="test(this)">abc</div> <!-- this 指这个对象 img-->

 




原标题:js this的使用举例

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

全球物流巨头:https://www.goluckyvip.com/tag/2109.html
GuluPark:https://www.goluckyvip.com/tag/21090.html
Gump Ye:https://www.goluckyvip.com/tag/21091.html
Gumtree:https://www.goluckyvip.com/tag/21092.html
Guru:https://www.goluckyvip.com/tag/21093.html
gurunanda dev:https://www.goluckyvip.com/tag/21094.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
23点聊电商:“潮起钱塘·境遇未来”2024年跨境电商全平台发展大会圆满完成 :https://www.kjdsnews.com/a/1836652.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流