国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

BootStrap modal實現拖拽功能

2024-05-06 15:27:38
字體:
來源:轉載
供稿:網友

bootstrap中有javascript插件modal也就是對話框,加入拖拽功能,具體內容如下

在使用modal時首選需要引用js

<link  rel="stylesheet"><script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.js"></script><script src="https://cdn.bootcss.com/jqueryui/1.11.4/jquery-ui.js"></script> // 完成拖拽功能<script src="https://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.js"></script> // 完成Modal

編輯Html代碼

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>BootStrap Modal</title> <link  rel="external nofollow" rel="external nofollow" rel="stylesheet"> <script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.js"></script> <script src="https://cdn.bootcss.com/jqueryui/1.11.4/jquery-ui.js"></script> <script src="https://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.js"></script></head><body> <button class="btn btn-default">顯示Modal</button>  <div class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">Modal title</h4> </div> <div class="modal-body"> <p>One fine body…</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> <!-- /.modal-content -->  </div> <!-- /.modal-dialog -->  </div> <!-- /.modal --><script type="text/javascript"> var $button = $('.btn-default'), $modal = $('#myModal'); $(function(){ $button.on('click',function(event) { event.preventDefault(); /* Act on the event */ $modal.show( '500', function() { var modal = $(this); modal.find('.modal-title').text('New message to '); $.ajax({}); }); $modal.modal('show'); }); }); </script> </body></html>

要完成拖拽功能需要修改一下javascript

<script type="text/javascript"> var $button = $('.btn-default'), $modal = $('#myModal'); $(function(){ $button.on('click',function(event) { event.preventDefault(); /* Act on the event */ $modal.show( '500', function() { var modal = $(this); modal.find('.modal-title').text('New message to '); $.ajax({}); }); /* 完成拖拽 */ $modal.draggable({ cursor: "move", handle: '.modal-header' }); $modal.modal('show'); });});</script>

推薦

有關bootstrap modal插件使用詳細請看:鏈接地址

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 民和| 陕西省| 依兰县| 綦江县| 固镇县| 九江市| 杭锦旗| 霸州市| 鄂尔多斯市| 克拉玛依市| 镇安县| 洪湖市| 晋城| 东宁县| 隆子县| 康平县| 克东县| 姜堰市| 石泉县| 雅江县| 灵武市| 建水县| 崇文区| 常山县| 义马市| 慈溪市| 榕江县| 西峡县| 保康县| 新竹县| 上饶市| 扎兰屯市| 织金县| 红桥区| 威海市| 永丰县| 洛浦县| 泽库县| 曲麻莱县| 梧州市| 霞浦县|