version - Fiddle not working in new jQuery -
i made fiddle old jquery website utilize new jquery, , don't know how create code work again. here are:
working: http://jsfiddle.net/hthgb/3626/ not working: http://jsfiddle.net/hthgb/3627/html
<div id="button"><button>toggle</button></div> <div id="zelena"></div>
javascript
$('#button').toggle( function() { $('#zelena').animate({right: -200}) }, function() { $('#zelena').animate({right: 0}) })
css
html, body { margin: 0; padding: 0; border: 0; } #zelena { top: 0px; right: 0px; bottom: 0px; width: 200px; background:green; position: absolute; } #button { left: 0px; position: absolute; }
the toggle event deprecated , removed. however, wrote a little plugin can same thing toggle
event did. however, not need plugin in case; few lines should it:
$('#button').on('click', function() { var zln = $('#zelena'), right = +zln.css("right").replace(/px/i, ''); right = right === 0 ? -200 : 0; zln.animate({right: right}) });
demo
jquery version jsfiddle
No comments:
Post a Comment