How to make textbox in Javascript slide left and right once the button is pressed?

13 0 1



I have a textbox which toggle between "visible" and "hidden" in javascript.This is the code:

 <a class="searchbar_header">
      <form class="search" action="/search">
        <script src=""></script>
    <input id="myTextBox" class="box" type="text" name="q" value="{{ search.terms | escape }}"  />
    <input type="button" " id="btnImg"  class="buttonImage" width="20" height="20" onclick="myFunctionClick()" />
       function myFunctionClick() {
   var x = document.getElementById("myTextBox");
    if ( === "hidden") { = "visible";
  } else { = "hidden";

 with the visibility in .css initially to "hidden".Once the input type=button is pressed,I would like the textbox to slide to the left and back again to the right every time the button is pressed.I have tried to do it with JQuery but without any luck,or it was sliding left,but after I press the button again it was disappearing as it normally should without any effect.This is what I have tried in JQuery:

                                 $(".buttonImage").click(function() {

/* and also */
$("#btnImg").click(function() {
    'right': '0px',
    'opacity': '1'
/*this one works but only once when I initially click the button.If I click again it will not work.I have also tried with the condition that if it is visible, to slide left and if it is hidden to slide right".*/

 Can anyone please help me make it so that when I click on the button,it will slide left and when i press again,where the case will be "hidden",it will slide right and do that continuously?