BootStrap modal實(shí)現(xiàn)拖拽功能
bootstrap中有javascript插件modal也就是對話框,加入拖拽功能,具體內(nèi)容如下
在使用modal時(shí)首選需要引用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>
<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>
推薦
有關(guān)bootstrap modal插件使用詳細(xì)請看:鏈接地址
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- BootStrap table實(shí)現(xiàn)表格行拖拽效果
- 詳解為Bootstrap Modal添加拖拽的方法
- 基于bootstrap的上傳插件fileinput實(shí)現(xiàn)ajax異步上傳功能(支持多文件上傳預(yù)覽拖拽)
- .net core版 文件上傳/ 支持批量上傳拖拽及預(yù)覽功能(bootstrap fileinput上傳文件)
- bootstrap模態(tài)框?qū)崿F(xiàn)拖拽效果
- Bootstrap模態(tài)框水平垂直居中與增加拖拽功能
- JS組件Bootstrap Table表格多行拖拽效果實(shí)現(xiàn)代碼
- JS組件Bootstrap Table表格行拖拽效果實(shí)現(xiàn)代碼
相關(guān)文章
CocosCreator怎樣使用cc.follow進(jìn)行鏡頭跟隨
這篇文章主要介紹了CocosCreator怎樣使用cc.follow進(jìn)行鏡頭跟隨,想要學(xué)習(xí)follow的同學(xué),一定要看一下2021-04-04
JavaScript實(shí)現(xiàn)鼠標(biāo)移動事件畫筆
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)鼠標(biāo)移動事件畫筆,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08
js實(shí)現(xiàn)改進(jìn)的仿藍(lán)色論壇導(dǎo)航菜單效果代碼
這篇文章主要介紹了js實(shí)現(xiàn)改進(jìn)的仿藍(lán)色論壇導(dǎo)航菜單效果代碼,涉及JavaScript頁面元素的遍歷及樣式動態(tài)變換技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09
微信小程序?qū)崿F(xiàn)全局狀態(tài)管理的方法整理
已知微信小程序中如果要做到全局狀態(tài)共享,常用的有四種方式,分別是globalData、本地緩存、mobx-miniprogram和westore,本文將帶大家看看mobx-miniprogram是如何實(shí)現(xiàn)的小程序的全局狀態(tài)管理,需要的可以收藏一下2023-06-06
JS字符串去除連續(xù)或全部重復(fù)字符的實(shí)例
這篇文章主要介紹了JS字符串去除連續(xù)或全部重復(fù)字符的實(shí)例,需要的朋友可以參考下2018-03-03
Bootstrap中datetimepicker使用小結(jié)
這篇文章主要為大家詳細(xì)介紹了Bootstrap中datetimepicker的使用方法,一款功能強(qiáng)大的日期選擇控件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12
JavaScript?對象新增方法defineProperty與keys的使用說明
這篇文章主要介紹了JavaScript對象新增方法defineProperty與keys的使用說明,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下2022-09-09

