此功能不起作用..无法弄清楚为什么...没有错误...但是当我单击它时图像不会缩小。
image_element.addEventListener( "click", function( )
{
this.style.width = ( parseInt( this.style.width ) - 1 ) + 'px';
this.style.height = ( parseInt( this.style.height ) - 1 ) + 'px';
}, false );
最佳答案
this
,在 eventListener 的上下文中,是 [引发事件的] 元素。您可能遇到的一个问题是 this.style.width
可能尚未指定...
记录/提醒 this.style.width
的值并首先查看其中的内容。
关于javascript - 概念 - `this` 在 addEventListener 回调中指的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10839433/