5 Star 0 Fork 0

guozhengyang/git-day02-fourth

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.js 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
bujiangwud 提交于 2023-04-28 22:43 . style:样式修改
const card = document.querySelectorAll(".card");
card.forEach((item,index) =>{
if (index !==1) {
item.addEventListener("click", () => alert(item.innerText))
}
}
);
const arr = [
"https://ts1.cn.mm.bing.net/th/id/R-C.9016d188bb6eec34ab0796cc0ee2f66c?rik=ce3O%2bF%2bHqPSBCA&riu=http%3a%2f%2fp0.ifengimg.com%2fpmop%2f2018%2f0816%2f83B8A87C4AF6111174A3545AC470428E16E21F01_size101_w1080_h1350.jpeg&ehk=ES%2fNOM6L7HjAe25TjcDkI1vXWIq9WYxR2nEgdVYSJyY%3d&risl=&pid=ImgRaw&r=0",
"https://tse2-mm.cn.bing.net/th/id/OIP-C.oMzqAAum12qa5FETd5XmFQHaJQ?pid=ImgDet&rs=1",
"https://ts1.cn.mm.bing.net/th/id/R-C.35adc3ebcb68c140abea3b9a0aba10dc?rik=iUzXTErHBp%2b0VA&riu=http%3a%2f%2fwww.uweekly.sg%2fwp-content%2fuploads%2f2015%2f04%2fPakho-%e5%91%a8%e6%9f%8f%e8%b1%aa.jpg&ehk=w8mleYIblCqIySniriWIi%2fOh8jRuobNhz9k0vOV6IPs%3d&risl=&pid=ImgRaw&r=0",
];
const wga = document.querySelector("#wga");
let index = 0;
wga.style.backgroundImage = `url(${arr[index]})`;
setInterval(() => {
index++;
index = index >= arr.length ? 0 : index;
wga.style.backgroundImage = `url(${arr[index]})`;
}, 800);
const kaixiang=document.querySelector('#kx')
kaixiang.addEventListener('click',function(e){
this.querySelector("span").innerText="kaixiang"
document.querySelector('.kaixiang').style.display="none"
document.querySelector('.kaixiang div').classList.toggle("bgcimg")
if (document.querySelector('.kaixiang div').classList.contains("bgcimg")) {
document.querySelector('.kaixiang').style.display="flex"
alert("你好我叫kaixiang,这是我喜欢的运动")
this.querySelector("span").innerText=""
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/guozhengyang666/git-day02-fourth.git
git@gitee.com:guozhengyang666/git-day02-fourth.git
guozhengyang666
git-day02-fourth
git-day02-fourth
master

搜索帮助