博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Web笔记-layerui的基本使用及JavaScript回调函数的写法
阅读量:1950 次
发布时间:2019-04-27

本文共 1100 字,大约阅读时间需要 3 分钟。

程序运行截图如下:

第一个按钮按下后:

第二个按钮按下后:

然后回调一个函数,这个函数调用系统自带的alert。

使用layerui的目的是为了统一弹窗的风格,因为不同浏览器alert的位置大小,风格不一样。

程序结构如下:

相关源码如下:

index.html

layer

common.js

;var common_ops = {    alert:function( msg ,cb){        layer.alert( msg,{            yes:function( index ){                if( typeof cb == "function" ){                    cb();                }                layer.close( index );            }        } );    }};

test.js

;var member = {    init:function(){        this.eventBind();    },	eventBind:function(){				$(".do-test").click(function(){						common_ops.alert("第一个 common_ops.alert");						//这是一个callback			var callback = function(){								alert("alert弹窗")			}									//第二个			//common_ops.alert("第二个 common_ops.alert", callback);		})	}};var member2 = {    init:function(){        this.eventBind();    },	eventBind:function(){				$(".do-test2").click(function(){									//这是一个callback			var callback = function(){								alert("alert弹窗")			}									//第二个			common_ops.alert("第二个 common_ops.alert", callback);		})	}};$(document).ready( function(){	    member.init();	member2.init();});

 

转载地址:http://jdmif.baihongyu.com/

你可能感兴趣的文章
Spring MVC异常处理
查看>>
PHP 7 的五大新特性
查看>>
php实现socket(转)
查看>>
PHP底层的运行机制与原理
查看>>
深入了解php底层机制
查看>>
PHP中的stdClass 【转】
查看>>
XHProf-php轻量级的性能分析工具
查看>>
PHP7新特性 What will be in PHP 7/PHPNG
查看>>
比较strtr, str_replace和preg_replace三个函数的效率
查看>>
ubuntu 下编译PHP5.5.7问题:configure: error: freetype.h not found.
查看>>
PHP编译configure时常见错误 debian centos
查看>>
configure: error: Please reinstall the BZip2 distribution
查看>>
OpenCV gpu模块样例注释:video_reader.cpp
查看>>
【增强学习在无人驾驶中的应用】
查看>>
OpenCV meanshift目标跟踪总结
查看>>
人工神经网络——神经元模型介绍
查看>>
今天,Python信息量很大!
查看>>
Flash 已死,Deno 当立?
查看>>
编程差的程序员,90%都是吃了数学的亏!骨灰级开发:方法不对,努力也白费...
查看>>
都无代码了,还要程序员吗?
查看>>