Sliding Pop Up Button Open and Close
Hello Everyone. I am looking for a way to make the following code have the button switch between one color to another.
Any suggestions would be great.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>slide demo</title>
<style>
body{
margin:0;
}
.pollSlider{
position:fixed;
height:100%;
background:red;
width:200px;
right:0px;
margin-right: -200px;
}
#pollSlider-button{
position:fixed;
width:100px;
height:50px;
right:0px;
background:green;
top:300px;
}
</style>
<script src="
" target="_blank">http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="
" target="_blank">http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>
<div class="pollSlider"></div>
<div id="pollSlider-button"></div>
<script type="text/javascript">
- $(document).ready(function () {
- $('#pollSlider-button').click(function () {
- if ($(this).css("margin-right") == "200px") {
- $('.pollSlider').animate({
- "margin-right": '-=200'
- });
- $('#pollSlider-button').animate({
- "margin-right": '-=200'
- });
- } else {
- $('.pollSlider').animate({
- "margin-right": '+=200'
- });
- $('#pollSlider-button').animate({
- "margin-right": '+=200'
- });
- }
- }). click(); // this click call makes a fake click to start the page with an animated menu popping out.
- });
</script>
</body>
</html>