【发布时间】:2014-02-27 10:48:35
【问题描述】:
当我点击按钮时会发生什么?为了保持原位,按钮向下移动并 返回到.. 这是一个 HTML、CSS 和 jQuery 代码...这个想法是当我单击按钮时,搜索表单向左移动。当我再次单击该按钮时,搜索表单会向后移动。
HTML
<form action="" class="search">
<input type="text" placeholder="Search" class="input" />
<input type="button" value="click me"/>
</form>
CSS
input[type="text"]
{
display: none;
width: 254px;
height: 63px;
border: none;
font-size: 30px;
font-family: SourceSansPro, sans-serif;
color: gray;
}
input[type="button"]
{
position: relative;
float: right;
left: -10px;
border: none;
width: 63px;
height: 63px;
padding: 0;
}
jQuery
$('input[type=button]').click(function () {
// Set the effect type
var effect = 'slide';
// Set the options for the effect type chosen
var options = { direction: 'right' };
// Set the duration (default: 400 milliseconds)
var duration = 700;
$('input[type=text]').toggle(effect, options, duration);
});
【问题讨论】:
标签: jquery forms button toggle