Javascript jQuery赢得';除非重新加载网页,否则无法再次运行
我已经创建了一个联系人表单,当我单击按钮时,我希望从右侧滑入该表单,当单击单独的按钮时,我希望滑回该表单。到目前为止,我只能使用.hide()方法,但当我再次单击按钮查看表单时,它不起作用。谁能解释一下原因吗 这是我的html代码Javascript jQuery赢得';除非重新加载网页,否则无法再次运行,javascript,jquery,css,Javascript,Jquery,Css,我已经创建了一个联系人表单,当我单击按钮时,我希望从右侧滑入该表单,当单击单独的按钮时,我希望滑回该表单。到目前为止,我只能使用.hide()方法,但当我再次单击按钮查看表单时,它不起作用。谁能解释一下原因吗 这是我的html代码 <div id="slidebottom" class="slide"> <button id="button" class="btn btn-primary" role="button" data-toggle="colla
<div id="slidebottom" class="slide">
<button id="button" class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
</button>
<div class="well">
<form action="index.html" method="post">
<button id="close_button"><a><img id="close" src="img/close.png"></a></button>
<h1 class="heading">CONTACT US</h1>
<p>Register your interest and we will inform you of latest developments</p>
<input type="text" id="name" name="user_name">
<input type="email" id="email" name="user_email">
<input type="tel" id="phone" name="user_number">
<h1 class="register">REGISTER</h1>
</form>
</div>
@Pierreemanuellallemant我不认为这是真的。为什么在
var
之前有一个$
符号?.hide()
设置元素的显示:无
,如果你想再次看到它,你需要先将其反转。一个问题(除其他问题外)是关闭按钮在
内,因此,它将起到“提交”按钮的作用。给它type=button
以防止这种情况发生。@Pointy指向正确的点,按钮不能包含锚定。编辑:没有href设置,所以不确定它是否是交互式元素,但无论如何都不会使senseOk生效,但如何在隐藏元素上单击OP#close_按钮
是的子项。好吧
你说得对,我用一个完全不同的概念修改了代码
$(document).ready(function() {
$('#button').click(function() {
var $lefty = $(this).next();
$lefty.animate({
left: parseInt($lefty.css('left'),10) == 0 ?
-$lefty.outerWidth() :
0
});
});
});
$('#close_button').click(function() {
$('.well').hide();
});
$(document).ready(function() {
$('#button').click(function() {
var $lefty = $(this).next();
$('.well').show();
$lefty.animate({
left: parseInt($lefty.css('left'),10) == 0 ?
-$lefty.outerWidth() :
0
});
});
});