0

I'm using show function in my script. i m also passing parameters in that function, but it showing error. im using below code, while click a button i call this next() function.

function next() {
    $('#img1').hide('slide', { direction: 'left' }, 1400);
}

this is not worked for me. showing this error Uncaught TypeError: n.easing[this.easing] is not a function. while passing without parameters it works fine.

3
  • Do you want to use animation? Commented May 29, 2016 at 7:31
  • I need to hide and show img while click next and another prev button accordingly, so i go with this. Commented May 29, 2016 at 7:34
  • @Raja user loccai (lacking comment rep atm.) wants to know if you were able to get rid of this. Your code snippet works as expected... :-/ Commented Feb 23, 2018 at 0:24

2 Answers 2

2

Use this code

$("button").click(function(){
    $("div").animate({width:'toggle'}, 350);
});
div {
    width: 100px;
    height: 100px;
    background: green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>Show/hide</button>
<br/><br/>
<div></div>

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer but i want to hide left. like a slide. jsfiddle.net/xu3ck/16 here it works but in my code not working.
1

What about a customized animation as below:

HTML

<div class='div1' id="div1"></div>
<button id="showhide"></button>

CSS

.div1{
  height:100px;
  width:100px;
  position:absolute;
  left:0;
  top:100px;
  background-color:red;
  transition:all 0.5s;
}
.hide{
  width:0;  
}

JS

document.getElementById("showhide").addEventListener("click",function(){
   if(document.getElementById("div1").classList.contains("hide")){
        document.getElementById("div1").classList.remove("hide");
   }
   else{
        document.getElementById("div1").classList.add("hide");
   }
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.