如何放大按钮,因为它获得焦点? [英] How to enlarge a button as it receives focus?

查看:117
本文介绍了如何放大按钮,因为它获得焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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

任何想法如何使它工作?

解决方案

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

我想在实现这个之后,您还需要在焦点离开后恢复大小。

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

如果您所做的不仅仅是这些,我会建议将这些代码分解为多个函数并使其更好JavaScript设计决策。

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?

解决方案

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

这篇关于如何放大按钮,因为它获得焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆