Codice javascript
codice:
<script type='text/javascript'>
function posizione()
{
// valore posizione
var p= document.getElementById('nav').style.left;
//alert( p);
// condizione
if ( p == "-250px")
{destra()}
else
{sinistra()}
}
//$(document).ready(function() {
//$('#nav').animate({left: 200}, 1000);
//$('#nav').animate({left:0}, 1000);
//});
function destra()
{$('#nav').animate({left:0}, 1000); }
function sinistra()
{$('#nav').animate({left: -250}, 1000); }
</script>
Ciodice div metti queste propietà nello style
codice:
<div id="nav"
style="position: relative;left: -250px;width: 300px;height:500px;background: #333;"
onClick="posizione()" ></div>