使用javascript调整按钮图像

Tom*_*ito 1 html javascript

当我点击它时,我希望以下按钮(和它的图像)改变大小.对话框正在显示,但大小没有变化..

<html>
    <input type="image" src="pacman.png"  onClick="
        alert('test');
        this.height='200px'; // change de button size
        // this.image.height='200px'; // not sure if this line will work..
    "/>
</html>
Run Code Online (Sandbox Code Playgroud)

需要在javascript中,没有在CSS中,因为我稍后会制作动画..

Poi*_*nty 6

你必须操纵"style"属性:

this.style.height = '200px';
Run Code Online (Sandbox Code Playgroud)