Javascript 我怎么才能在这里关闭覆盖模式框,它不工作
我无法关闭覆盖模式框。我尝试在单击x时删除类列表,然后关闭模式框,但js和css无法识别它。首先,我有一个椭圆形区域,其中应显示COA的名称和位置,之后,当用户单击箭头时,模式框会以全宽和全高弹出,这是正确的,之后我有一个X span@次,当我单击X时,我希望mdoal框被禁用。我尝试了addevent listener,但一切都不起作用 JS代码Javascript 我怎么才能在这里关闭覆盖模式框,它不工作,javascript,css,Javascript,Css,我无法关闭覆盖模式框。我尝试在单击x时删除类列表,然后关闭模式框,但js和css无法识别它。首先,我有一个椭圆形区域,其中应显示COA的名称和位置,之后,当用户单击箭头时,模式框会以全宽和全高弹出,这是正确的,之后我有一个X span@次,当我单击X时,我希望mdoal框被禁用。我尝试了addevent listener,但一切都不起作用 JS代码 const makingTheInstructorSection = (arrInst) => { for(let coach of ar
const makingTheInstructorSection = (arrInst) => {
for(let coach of arrInst) {
$('.instructorBoxes').append
(`
<div class="infoPerInstructor">
<img src="ImageGalleryPictures/instructor.jpg"/>
<div class="firstOverlay">
<p class="arrowPointerInstructor">→</p>
<div class="text">
<p class="arrowPointerInstructor">→</p>
<h3>${coach.name}</h3>
<p>${coach.position}</p>
</div>
</div>
<div class="secondOverlayOnClick">
<span class="closeTheInstructorBox">×</span>
<h5>Why you coach:</h5>
<p>${coach.WhyYouCoach}</p>
<h5>Favorite Movement:</h5>
<p>${coach.favoriteMovement}</p>
<h5>Favorite Quote:</h5>
<p>${coach.favoriteQuote}</p>
</div>
</div>
`)
}
}
// the code that i am trygin first,i am nto removing here
// because even here i dont get the span "x" in the console
// when i click that x in the browser
for(let item of closing) {
item.addEventListener("click" , (e) => {
console.log(e.target);
})
}
我找到了一个答案。因为它是重叠的,所以它不起作用,最好的方法是在主体上创建AddEventListener,然后检查 如果某个事件目标包含特定的类列表,则会找到它,通过该事件,您可以根据html上的结构搜索“模式框”,并删除某些类列表等
body.addEventListener("click" , (e) => {
if(e.target.classList.contains("closeTheInstructorBox")) {
console.log("x e ");
console.log(e.target.parentElement)
e.target.parentElement.remove("activeteTheSecondOverlayOnClick")
}
我在你的代码中看不到
点击
侦听器(用于点击X)。我现在更新了问题Mosh Feu,但它不起作用什么是关闭
?好的“聪明人”我找到了解决方案,不要无聊,玩“聪明人”