如何在点击时展开文本区域 [英] how to expand a text area when click on

查看:95
本文介绍了如何在点击时展开文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在一个小项目,它有一个textarea,我需要帮助,使文本区域扩展的鼠标点击像twitter和Facebook的。

Im working on a small project which has a textarea and i need help in making the text area expand on mouse click like that of twitter and facebook. the textarea should look like a textfield at first then when clicked on should expand.

推荐答案

像这样的东西会工作...

Something like this would work...

演示: http://jsfiddle.net/Y3rMM/

CSS ...

.expand {
    height: 1em;
    width: 50%;
    padding: 3px;
}

HTML ...

<textarea class="expand" rows="1" cols="10"></textarea>

jQuery ...

jQuery...

$('textarea.expand').focus(function () {
    $(this).animate({ height: "4em" }, 500);
});

这篇关于如何在点击时展开文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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