Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <html>
  2.  
  3. <h2>Choose step size:</h2>
  4. 1 px <input type="radio" id="small" name="move" value="1" checked="checked"><br>
  5. 10 px <input type="radio" id="medium" name="move" value="10"><br>
  6. 100 px <input type="radio" id="large" name="move" value="100"><br>
  7.  
  8. <div class='a' id="mainDiv" onmouseover=" move();"></div>
  9.  
  10. <script type="text/javascript">
  11. $( document ).ready( function(){
  12. $('#mainDiv').mouseover(function(){
  13. var stepSize = parseInt( $('input[type=radio][name=move]:checked').val() );
  14.  
  15. var pos = $( this ).position();
  16. var left = parseInt( pos.left );
  17. var top = parseInt( pos.top );
  18.  
  19. var new_left = left + stepSize;
  20. var new_top = top + stepSize;
  21.  
  22. $( this ).css('left', new_left + 'px' );
  23. $( this ).css('top', new_top + 'px' );
  24. });});
  25. </script>
  26. <style>
  27. div.a {
  28. width: 80px;
  29. height:80px;
  30. background-color:blue;
  31. position:absolute;
  32.  
  33. }
  34. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement