views:

53

answers:

1

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

<html>
    <form name="myForm">
      <button onfocus="width=200; height=200">myButton</button>
      <button>myOtherButton</button>
    </form>
</html>

Any idea how can I make it work?

+3  A: 
<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.

palswim