English | 正體中文 | 简体中文

Jquery ui basic draggable



范例程式码 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 () {
      $("div[id^='drag']").draggable();
  });
</script>

<!-- HTML -->
<style>
    .drag { 
        width: 100px; 
        height: 100px;     
        border:1px solid black; 
        cursor:pointer;
        border-radius:10px;
        float:left;
        margin-left:5px;
        text-align:center;
        line-height:100px;
    }
</style>
<div id="drag1" class="drag" style="background-color:orange">Drag me</div>
<div id="drag2" class="drag" style="background-color:lightblue">Drag me</div>
<div id="drag3" class="drag" style="background-color:lightgreen">Drag me</div>
<div id="drag4" class="drag" style="background-color:lightyellow">Drag me</div>
<div id="drag5" class="drag" style="background-color:lightgray">Drag me</div>

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