Skip to content

Instantly share code, notes, and snippets.

@Microsofttechies
Created September 16, 2014 18:01
Show Gist options
  • Select an option

  • Save Microsofttechies/d0d5cc04d9b991b15f39 to your computer and use it in GitHub Desktop.

Select an option

Save Microsofttechies/d0d5cc04d9b991b15f39 to your computer and use it in GitHub Desktop.
slide toggle from right to left and left to right using jquery
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>slide demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<style>
#toggle
{
width: 900px;
height: 30px;
background: #ccc;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
</head>
<body>
<div id="toggle" style="width: 900px; padding-top: 10px;">
<div style="float: left;">Hello</div>
<div style="padding-right: 20px; float: right;">
<div id="close" style="cursor: pointer">&lt;</div>
<div id="open" style="display: none; cursor: pointer">&gt;</div>
</div>
</div>
<script>
$("#close").click((function () {
return function () {
$("#close").hide();
$("#open").show();
$("#toggle").animate({
width: "100px"
}, 10);
}
})());
$("#open").click((function () {
return function () {
$("#close").show();
$("#open").hide();
$("#toggle").animate({
width: "900px"
}, 10);
}
})());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment