English | 正體中文 | 简体中文

Jquery ui draggable handles



范例程式码 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 () {
        $("#drag").draggable({
            handle: "#handle"
        });
      
      	$("#drag1").draggable({
            cancel: "#handle1"
        });
    });
</script>

<!-- HTML -->
<style>
    .drag { 
        width: 100px; 
        height: 100px;     
        border:1px solid black;         
        border-radius:10px;
        padding:5px;
        margin-left:5px;
        text-algin:center;
        float:left;
    }
</style>
<div id="box" style="width:600px;height:200px;border:0px solid black;margin-bottom:5px">
    <div id="drag" class="drag">        
        <p id="handle" style="border:1px solid gray;background-color:yellow;cursor:pointer;text-align:center">handle</p>
        <p style="font-size:12px;">Drag me WITHIN yellow brick</p>
    </div>
  
  	<div id="drag1" class="drag" style="cursor:pointer;">        
        <p id="handle1" style="border:1px solid gray;background-color:yellow;text-align:center;cursor:default;">handle</p>
        <p style="font-size:12px;">Drag me OUTSIDE yellow brick</p>
    </div>
</div>

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