如何在jQuery中隐藏表单提交上的滑块?

如何在jQuery中隐藏表单提交上的滑块?,jquery,forms,slider,submit,hide,Jquery,Forms,Slider,Submit,Hide,我使用jQuery插件在我的页面上显示一个滑块,我想在用户按下搜索按钮(提交表单)时隐藏它。 我该怎么做? 调用滑块的代码: <!-- Initialize the csstubeslider plugin --> <script type="text/javascript"> $(window).load(function(){ $("#gallery").csstubeslider(); }); </script> $

我使用jQuery插件在我的页面上显示一个滑块,我想在用户按下搜索按钮(提交表单)时隐藏它。 我该怎么做? 调用滑块的代码:

 <!-- Initialize the csstubeslider plugin -->
<script type="text/javascript">
    $(window).load(function(){
        $("#gallery").csstubeslider();
    });
</script>

$(窗口)。加载(函数(){
$(“#画廊”).csstubeslider();
});
我的html:

   <div id="gallery"><a href="#" class="show">
<img src="images/slider/s1.jpg" id="slideimg" />
</a>
<a href="#" <img src="images/slider/s2.jpg" id="slideimg" />
</a>

表格如下:

 <form class="searchform" action="webpage.php" method="POST">
<input class="searchfield autosuggest" type="text" name="name"  placeholder="Search for a name " onFocus="if (this.value == 'Search...') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Search...';}" />
<input class="searchbutton" type="submit" name"name" value="Go" />
</form>

使用:


您可以使用jquery在表单上收听submit,如下所示:

$('.searchbutton').submit(function() {
    $("#gallery").hide(); // hides the gallery 
    // alternative way: $("#gallery").css("display","none");
});

我已经试过了,但是没有用,我在问题中添加了表单代码以供参考。您使用
.searchform
作为选择器?你知道
你能解释为什么它无效吗?因为你不能在另一个标签中打开一个新标签,你应该先关闭你的锚链接,使用:
无论如何我已经解决了我的问题,但是在php中放置了一个if语句,并使用display:none。
$('.searchbutton').submit(function() {
    $("#gallery").hide(); // hides the gallery 
    // alternative way: $("#gallery").css("display","none");
});