jquery slideToggle direction -
i trying slide jquery .slidetoggle not able add direction left right or right left on click of div (nav). please me out, below code.
<!doctype html> <html> <head> <style> p { width:400px; float:right;background:#e4e4e4; margin:5px;padding:5px;} </style> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body style="font-size:10px; color:#333;"> <div style="width:50px; height:15px;float:right;background:#ccc;border:1px solid #333;text-align:center;">nav</div> <p> paragraph end paragraphs. should feel <em>lucky</em> have seen such paragraph in life. congratulations! </p> <script> $("div").click(function () { $("p").slidetoggle("slow"); }); </script> </body>
i new jquery, appreciated.
you need add parent text.
<body> <div class="nav">nav</div> <div class="text"> <p>this paragraph end paragraphs. should feel <em>lucky</em> have seen such paragraph in life. congratulations!</p> </div> </body>
style:
body { font-size: 10px; color: #333; } .nav { float: right; width: 50px; height: 30px; text-align: center; background: #ccc; border: 1px solid #333; } .text { overflow: hidden; float: right; margin: 5px; padding: 5px; width: 400px; background: #e4e4e4; }
and javascript:
$('.nav').click(function() { $('.text p').css({ 'width': $('.text p').width(), 'height': $('.text p').height() }); $('.text').animate({'width': 'toggle'}); });
you have demo at: http://jsfiddle.net/abwvd/
Comments
Post a Comment