利用bootstrap实现消息对话框插件



15 58 20



特效描述:利用bootstrap实现 消息对话框插件,利用bootstrap实现消息对话框插件

代码结构

1. 引入CSS

<link rel="stylesheet" href="bootstrap-4.0.0-dist/css/bootstrap.css">
<link rel="stylesheet" href="./css/bs4.pop.css">

2. 引入JS

<script src="js/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="bootstrap-4.0.0-dist/js/bootstrap.js"></script>
<script src="./js/bs4.pop.js"></script>

3. HTML代码

    <div class="container" style="padding:50px 0">
        <h1>bootstrap4.pop</h1>
        <div class="group">
            <button class="btn btn-primary" onClick="demo_dialog()">Dialog</button>
            <button class="btn btn-primary" onClick="bs4pop.alert('我是对话框内容', function(){ console.log('我按了确定');})">Alert</button>
            <button class="btn btn-primary" onClick="bs4pop.confirm('你确定要退出系统吗?', function(sure){ console.log('我按了确定吗:', sure);})">Confirm</button>
            <button class="btn btn-primary" onClick="bs4pop.prompt('你算老几?', '第捏', function(sure, value){ console.log('我算老:', value);})">Prompt</button>
            <hr>
            <p>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'topleft'})">Notice topleft</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'topcenter'})">Notice topcenter</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'topright'})">Notice topright</button>
            </p>
            <p>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'center'})">Notice center</button>
            </p>
            <p>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'bottomleft'})">Notice bottomleft</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'bottomcenter'})">Notice bottomcenter</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {position: 'bottomright'})">Notice bottomright</button>
            </p>
            <hr>
            <p>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'primary'})">Notice primary</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'secondary'})">Notice secondary</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'success'})">Notice success</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'danger'})">Notice danger</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'warning'})">Notice warning</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'info'})">Notice info</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'light'})">Notice light</button>
                <button class="btn btn-primary" onClick="bs4pop.notice('这个是消息内容', {type: 'dark'})">Notice dark</button>
            </p>
        </div>
    </div>
	<script>
		function demo_dialog(){
			let dia = bs4pop.dialog({
				title: '对话框标题, 我还能拖拽呢',
				content: '我是对话框内容',
				closeBtn: true,
				backdrop: 'static',
				btns: [
					{label: '确定',	className: 'btn-primary', onClick(cb){}},
					{label: '取消',	className: 'btn-default', onClick(cb){}}
				],
				onShowStart: function(){
					// console.log('onShowStart');
				},
				onShowEnd: function(){
					// console.log('onShowEnd');
				},
				onHideStart: function(){
					// console.log('onHideStart');
				},
				onHideEnd: function(){
					// console.log('onHideEnd');
				},
				onDragStart: function(){
					console.log('onDragStart');
				},
				onDragEnd: function(){
					// console.log('onDragEnd');
				},
				onDrag: function(){
					console.log('onDrag');
				}
			});
			setTimeout(() => {
				// dia.hide()
			}, 2000);
		}
		function demo_alert(){
		}
		setTimeout(() => {
			$('#alert').alert();
			setTimeout(() => {
				$('#alert').alert('close');
			}, 2000);
		}, 2000);
	</script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 弹出层拖动 窗口 弹出 弹窗 弹出层 提示框 对话框 遮罩 遮罩层 弹窗插件 切换按钮 表单 表单美化 表单插件 表单美化插件 文字提示框 提示文字 提示框/弹出层 按钮控制
×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到