JavaScript-封装弹框插件

文章讲述了如何使用JavaScript动态创建一个蓝色div,并分享了一个封装的弹窗功能。同时,作者介绍了一套完整的2024年Web前端开发学习资料,包括零基础至进阶课程,以及面试题库,旨在帮助前端工程师系统学习和提升技能。
摘要由CSDN通过智能技术生成
是否添加一个页面生成一个蓝色div
确定
取消

`

document.body.appendChild(shade);

var cancel = document.querySelector(“.btn.cancel”);

cancel.onclick = function() {

document.body.removeChild(shade);

}

var confirmDiv = document.querySelector(“.btn.confirm”);

confirmDiv.onclick = function() {

var a = document.createElement(“div”)

a.style.backgroundColor = “red”;

a.style.width = “100px”;

a.style.height = “100px”;

document.body.appendChild(a);

document.body.removeChild(shade)

}

}

tanchuang.css

  • {

margin: 0;

padding: 0;

box-sizing: border-box;

}

.shade {

display: flex;

top: 0;

left: 0;

width: 100%;

height: 600px;

background-color: rgba(0, 0, 0, 0.5);

}

.shade .popwindows {

width: 400px;

height: 300px;

background-color: #f2f2f2;

position: absolute;

left: 50%;

top: 50%;

transform: translate(-50%, -50%);

display: flex;

flex-direction: column;

}

.shade .popwindows .tltle {

position: relative;

display: flex;

flex-direction: row;

align-items: center;

width: 100%;

flex: 1;

border-bottom: 1px solid #bdb8b8;

}

.shade .popwindows .tltle .text {

flex: 1;

float: left;

padding-left: 10px;

font-family: “微软雅黑”;

}

.shade .popwindows .tltle .exit {

width: 30px;

height: 30px;

background-image: url(“…/js学习/imag/cuohao.png”);

background-repeat: no-repeat;

background-position: center center;

background-size: 20px auto;

float: right;

margin-right: 10px;

}

.shade .popwindows .content {

width: 100%;

flex: 3;

line-height: 40px;

font-size: 13px;

margin-left: 10px;

font-family: ‘宋体’;

}

.shade .popwindows .endbtn {

display: flex;

justify-content: center;

align-items: center;

width: 100%;

flex: 1;

border-top: 1px solid #bdb8b8;

}

.shade .popwindows .endbtn .btn{

width: 80px;

text-align: center;

height: 30px;

line-height: 30px;

font-size: 15px;

background-color: #979797;

}

.shade .popwindows .endbtn .btn:nth-child(1){

margin-right: 10px;

}

.shade .popwindows .endbtn .btn:nth-child(2){

margin-right: 10px;

}

.shade .popwindows .endbtn .btn:hover{

background-color: #f68c4e;

}

在这里插入图片描述封装

Document

添加弹窗

/*

var args = {

title:“温馨提示”,

content:“是否添加一个页面生成一个蓝色div”,

confirmDivfn:function(){

var a = document.createElement(“div”);

a.style.backgroundColor = “red”;

a.style.width = “100px”;

a.style.height = “100px”;

body.appendChild(a);

},

cancelfn:function(){

body.removeChild(shade);

}

}

*/
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(资料价值较高,非无偿)

最后

正值金三银四招聘旺季,很多小伙伴都询问我有没有前端方面的面试题,特地整理出来赠送给大家!

资料领取方式:点击这里前往获取

本涵盖了95%以上前端开发知识点,真正体系化!**

[外链图片转存中…(img-ohrcJ2cb-1711672751675)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(资料价值较高,非无偿)

最后

正值金三银四招聘旺季,很多小伙伴都询问我有没有前端方面的面试题,特地整理出来赠送给大家!

资料领取方式:点击这里前往获取

前端资料图.PNG

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值