代码之家  ›  专栏  ›  技术社区  ›  Student

使用javascript调整按钮图像大小

  •  0
  • Student  · 技术社区  · 14 年前

    我想下面的按钮(和它的图像)改变大小,当我点击它。对话框正在显示,但大小不变。。

    <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>
    

    需要在javascript中,没有在css中,因为我稍后会制作一个动画。。

    2 回复  |  直到 14 年前
        1
  •  6
  •   Pointy    14 年前

    必须操作“样式”属性:

    this.style.height = '200px';
    
        2
  •  2
  •   user454497 user454497    14 年前

    你可以用它

    this.style.height = "200px";
    

    但是,您应该看看jQuery,这是一个非常优秀的Javascript库,它非常容易做到这一点 ! 相信我,这个小小的学习曲线是值得的。 http://www.jquery.com