English | 正體中文 | 简体中文

Jquery ui basic droppable



范例程式码 Expand
<!-- Javascript -->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
    $(function () {
        $(".square").draggable();
        $(".squaredotted").droppable({
            drop: function (event, ui) {
                $("#info").html("dropped!");
            },
          	over: function( event, ui ) {
            	$("#info").html("moving in!");
            },
          	out: function( event, ui ) {
            	$("#info").html("moving out!");
            }
        });
    });
</script>

<!-- HTML -->
<style>
    .square {
  		width:100px;
        height:100px;
        border:1px solid black;         
        margin-bottom:5px;
        margin-left:5px;
        text-align:center;
        line-height:50px;
        float:left;
        background-color:lightblue;
    }
  
  	.squaredotted{
  		width:200px;
        height:200px;
        border:1px dotted gray;         
        margin-bottom:5px;
        margin-left:5px;
        text-align:center;
        line-height:50px;
        float:left;
    }
</style>
<div></div>
<div style="float:left">
    <div class="square">Drage me</div>          	
</div>
<div style="float:left;margin-left:50px;">
    <div class="squaredotted">Drop here</div> 
  	<div id="info"></div>
</div>

    
在线测试程序
© 2012 PureExample.com contact