Skip to content Skip to sidebar Skip to footer

How To Enlarge A Button As It Receives Focus?

I'm trying to make my button bigger when it receives focus:

Solution 1:

<form name="myForm">
    <button onfocus="this.style.width = '200px'; this.style.height = '200px';">myButton</button>
    <button>myOtherButton</button>
</form>

I imagine after implementing this, you will also want to restore the size after the focus leaves.

<button onfocus="this.style.width = '200px'; this.style.height = '200px';" onblur="this.style.width = this.style.height = '';">myButton</button>

If you're doing much more than that, I would recommend separating this code into functions and making better JavaScript design decisions.


Post a Comment for "How To Enlarge A Button As It Receives Focus?"