idris
idris

Reputation: 1049

Can't get search bar to go back up

So I have nav bar, with a search bar on top of it. When you want to search it'll appear. And when you're done it'll slide back up. The issue is, I can't get it to slide back up, I can only get it to slide down. Here's my code

$(document).ready(function(){
$(".icon-search").click(function(){
      $(".slip").toggleClass("slip-open"); 
      $("#FORM_1").removeAttr("style");
});

And a demo for the thing with CSS and markup http://jsfiddle.net/FjwPZ/2/

You'll see that the search bar slides down, but not back up. Any help would be great.

Upvotes: 1

Views: 26

Answers (1)

imbondbaby
imbondbaby

Reputation: 6411

Use toggle() instead of removeAttr

Toggles each of the set of matched elements. If they are shown, toggle makes them hidden. If they are hidden, toggle makes them shown.

Try this:

$(document).ready(function(){
$(".icon-search").click(function(){
      $(".slip").toggleClass("slip-open"); 
      $("#FORM_1").toggle();
});

JSFiddle Demo

Upvotes: 1

Related Questions