Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resize button image using javascript

I want the following button (and it's image) to change size when I click it. The dialog is showing, but the size is not changing..

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

Need be in javascript, no in the css, becouse I'll make an animation later..

like image 986
The Student Avatar asked Aug 23 '26 04:08

The Student


2 Answers

You have to manipulate the "style" property:

this.style.height = '200px';
like image 90
Pointy Avatar answered Aug 25 '26 18:08

Pointy


You can do it with

this.style.height = "200px";

BUT, you should look into jQuery, an excellent Javascript library which makes it really easy to do that plus a LOT more! It's worth the small learning curve, trust me. http://www.jquery.com


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!