[英]How to Open a Modal Using Javascript
I have an HTML code which have fab floating button when i click on that button i want to open a modal popup window but I don't know how to do it. 我有一个HTML代码,其中包含fab浮动按钮,当我单击该按钮时,我想打开一个模式弹出窗口,但我不知道该怎么做。
index.html index.html
<html>
<head>
<link rel="stylesheet" href="dist/css/kc.fab.css"/>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>
<h1 style="text-align: center;">Materialize Floating Action Button - jQuery plugin</h1>
<h2 style="text-align: center;">Please feel free to use and contribute! :)</h2>
<div class="kc_fab_wrapper" >
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="dist/js/kc.fab.min.js"></script>
<script>
$(document).ready(function(){
var links = [
{
"bgcolor":"red",
"icon":"+"
},
{
"url":"http://www.example.com",
"bgcolor":"red",
"color":"#fffff",
"icon":"<i class='fa fa-phone'></i>",
"target":"_blank"
},
{
"url":"http://www.example.com",
"bgcolor":"black",
"color":"white",
"icon":"<i class='fa fa-music'></i>"
}
]
$('.kc_fab_wrapper').kc_fab(links);
})
</script>
</body>
for more below demo is helpful http://www.jqueryscript.net/menu/Material-Design-Floating-Action-Button-with-jQuery-KC-FAB.html 下面的更多示例对演示很有帮助http://www.jqueryscript.net/menu/Material-Design-Floating-Action-Button-with-jQuery-KC-FAB.html
May I suggest having a look at http://materializecss.com 我可以建议看看http://materializecss.com
Fiddle example : https://jsfiddle.net/mikeferrari/a4xhxknk/ 小提琴示例 : https : //jsfiddle.net/mikeferrari/a4xhxknk/
Include the script and css file in your index.html page first 首先在index.html页面中包含脚本和CSS文件
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/js/materialize.min.js"></script>
I use this frequently and the documentation and example code is great. 我经常使用它,文档和示例代码很棒。 There is an easy to implement example for a modal button here:
这里有一个易于实现的模式按钮示例:
<!-- Modal Trigger -->
<a class="waves-effect waves-light btn" href="#modal1">Modal</a>
<!-- Modal Structure -->
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Modal Header</h4>
<p>A bunch of text</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.