Onclick Expand Textbox Width

后端 未结 6 768
滥情空心
滥情空心 2020-12-30 06:39

I want to use jQuery to expand the width of a input textbox during onclick.

For example, if the input has a default width of 100px, when the user clicks in it to ty

6条回答
  •  [愿得一人]
    2020-12-30 06:52

    I'd like to build on @wsanville's example by removing the extra step on saving the original size. Animation also takes string values like '+=50' or '-=50' for increasing/decreasing the width.

    See in in action on jsfiddle

    $('#box').focus(function()
    {
        $(this).animate({ width: '+=50' }, 'slow');
    }).blur(function()
    {
        $(this).animate({ width: '-=50' }, 'slow');
    });
    

提交回复
热议问题