Jump to Content

RSS Feeds:

Posts | Comments

http://ivanwlam.com/experiments/programming

Leave a Reply


PHP in Example

 <div>      <div id="box">      Just a box styled by jQuery. Can't do anything to it.      </div><!--end #box -->        <div id="dragBox">      You're supposed to be able to drag this box. Try it!      </div><!-- end #dragBox -->        <div id="dropBox">      Try to drop the box here!      </div><!-- end #dropBox -->  </div>

Written-out JavaScript at the end of the document

 $("#box").css({      "width":"100px",      "height":"200px",      "background-color":"#ffff00"      });    $("#dragBox")      .css({          "width":"200px",          "height":"100px",          "background-color":"#00ff00"          })      .draggable({          start: function (){              $(this).text("Dragging is now turned on! Drag the box around!");              },          drag: function (){              $(this).text("Dragging!");              },          stop: function (){              $(this).text("Dragging stopped. Try to pick it up again!");              }          });        $("#dropBox")      .css({          "width":"400px",          "height":"300px",          "background-color":"#999",          "float":"right"          })      .droppable({          drop: function() {              $(this)                  .css({                      "background-color":"#f00"                      })                  .text("You dropped the box!");              $("#dragBox")                  .css({                      "background-color":"#ccc"                      })                  .draggable('destroy')                  .text("Box is dropped. You can't take it out!");              },          tolerance: 'fit'          });