用动画放大输入元素
我想扩展输入字段。所以这几乎有效,但效果是“闪烁”。该字段展开和折叠,有趣的是,第二个输入会转到下一行。您能否给出如何以某种方式编写或重写它的建议!?!?!
jQuery
$('#menusearchform .s').mouseenter(function(){
var $this = $(this);
if (!$this.data('expand')) {
$this.data('expand', true);
$this.animate({width:'+=32px',left:'-=16px'});
}
$this.val("").focus();
}).mouseleave(function(){
var $this = $(this);
$this.data('expand', false);
$this.animate({width:'-=32px',left:'+=16px'});
});
HTML
<div id="divsearch">
<form method="post" action="index.php" id="menusearchform">
<input class="s" type="text" value="Search" name="felem1" />
<input class="s" type="text" value="Search" name="felem2" />
<input type="submit" value="Search" name="buttonSearch" />
<input type="reset" value="Reset" name="buttonReset" id="Reset"/>
</form>
</div>
I wanted to expand the input fields. So this almost works but the efect is "blinky". The field expands and colapses and intereseting makes the second input to go to the next row. Can you give any advise how to do it write or rewrite it in some way!?!?!
Jquery
$('#menusearchform .s').mouseenter(function(){
var $this = $(this);
if (!$this.data('expand')) {
$this.data('expand', true);
$this.animate({width:'+=32px',left:'-=16px'});
}
$this.val("").focus();
}).mouseleave(function(){
var $this = $(this);
$this.data('expand', false);
$this.animate({width:'-=32px',left:'+=16px'});
});
HTML
<div id="divsearch">
<form method="post" action="index.php" id="menusearchform">
<input class="s" type="text" value="Search" name="felem1" />
<input class="s" type="text" value="Search" name="felem2" />
<input type="submit" value="Search" name="buttonSearch" />
<input type="reset" value="Reset" name="buttonReset" id="Reset"/>
</form>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
猜测您不希望整个表单扩展。也许这就是您所需要的: http://jsfiddle.net/fpgAn/1/
Guessing you don't want whole form to expand. Maybe this is what you need: http://jsfiddle.net/fpgAn/1/