bootstrap中有javascript插件modal也就是對話框,加入拖拽功能,具體內(nèi)容如下
創(chuàng)新互聯(lián)主營建德網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,重慶APP軟件開發(fā),建德h5小程序開發(fā)搭建,建德網(wǎng)站營銷推廣歡迎建德等地區(qū)企業(yè)咨詢
在使用modal時首選需要引用js
<link rel="stylesheet"> <script src="http://cdn.bootcss.com/jquery/2.1.4/jquery.js"></script> <script src="http://cdn.bootcss.com/jqueryui/1.11.4/jquery-ui.js"></script> // 完成拖拽功能 <script src="http://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="http://cdn.bootcss.com/jquery/2.1.4/jquery.js"></script> <script src="http://cdn.bootcss.com/jqueryui/1.11.4/jquery-ui.js"></script> <script src="http://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> <h5 class="modal-title">Modal title</h5> </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>
推薦
有關(guān)bootstrap modal插件使用詳細請看:鏈接地址
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
網(wǎng)頁題目:BootStrapmodal實現(xiàn)拖拽功能
轉(zhuǎn)載來源:http://jinyejixie.com/article6/ppshig.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、動態(tài)網(wǎng)站、網(wǎng)站導航、響應式網(wǎng)站、網(wǎng)頁設計公司、用戶體驗
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)