Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我怎么才能在这里关闭覆盖模式框,它不工作_Javascript_Css - Fatal编程技术网

Javascript 我怎么才能在这里关闭覆盖模式框,它不工作

Javascript 我怎么才能在这里关闭覆盖模式框,它不工作,javascript,css,Javascript,Css,我无法关闭覆盖模式框。我尝试在单击x时删除类列表,然后关闭模式框,但js和css无法识别它。首先,我有一个椭圆形区域,其中应显示COA的名称和位置,之后,当用户单击箭头时,模式框会以全宽和全高弹出,这是正确的,之后我有一个X span@次,当我单击X时,我希望mdoal框被禁用。我尝试了addevent listener,但一切都不起作用 JS代码 const makingTheInstructorSection = (arrInst) => { for(let coach of ar

我无法关闭覆盖模式框。我尝试在单击x时删除类列表,然后关闭模式框,但js和css无法识别它。首先,我有一个椭圆形区域,其中应显示COA的名称和位置,之后,当用户单击箭头时,模式框会以全宽和全高弹出,这是正确的,之后我有一个X span@次,当我单击X时,我希望mdoal框被禁用。我尝试了addevent listener,但一切都不起作用

JS代码

const makingTheInstructorSection = (arrInst) => {
  for(let coach of arrInst) {
    $('.instructorBoxes').append
    (`
    <div class="infoPerInstructor">
      <img src="ImageGalleryPictures/instructor.jpg"/>

        <div class="firstOverlay">   
        <p class="arrowPointerInstructor">&#8594;</p> 
            <div class="text">
            <p class="arrowPointerInstructor">&#8594;</p> 
                <h3>${coach.name}</h3>
                <p>${coach.position}</p>
            </div>
        </div>

        <div class="secondOverlayOnClick">
        <span class="closeTheInstructorBox">&times;</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,但它不起作用什么是
关闭
?好的“聪明人”我找到了解决方案,不要无聊,玩“聪明人”