MyModal

原生js弹出层

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/463930/1177945/MyModal.js

نووسەر
wish king
وەشان
0.0.1.20230419051637
Created
2023-04-13
Updated
2023-04-19
مۆڵەت
نییە

简单js弹出层

截图:






在线预览:
https://jsrun.net/gddKp/embedded/all/light

使用示例:

document.querySelector("#test1").addEventListener("click", function(){
  new MyModal({
    top: '',
    width: '50%',
    height: 'auto',
    borderRadius: '5px',
    zIndex: 1010,
    //null,不显示title
    title: 'test1',
    //支持HTML格式,null不显示content
    content: 'Hello World!',
    //closeText:null,不显示关闭按钮
    closeText: '关闭',
    closeWidth: '',
    //okText:null,不显示ok按钮
    okText: '好了',
    okWidth: '',
    //closeFn和okFn可以省略
    closeFn: function (e) {
      console.log('closeFn clicked');
      e.myModal.close();
    },
    okFn: function (e) {
      console.log('okFn clicked');
      e.myModal.close();
    }
  }).show();
});