Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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_Jquery_Modal Window - Fatal编程技术网

Javascript 模态框适用于一个图元,但不适用于其他图元

Javascript 模态框适用于一个图元,但不适用于其他图元,javascript,jquery,modal-window,Javascript,Jquery,Modal Window,我已经创建了一个模式框,它工作得很好,但是当我将它应用到其他元素时,它只在第一个元素上工作。 这些元素是不同的图像,单击“打开”模式框时,每个模式框中包含不同的信息 这是 如果你有人能帮我解决这个问题,我将不胜感激 谢谢 这是HTML: <div id="myBtn"> <div class="container-team"> <img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploa

我已经创建了一个模式框,它工作得很好,但是当我将它应用到其他元素时,它只在第一个元素上工作。 这些元素是不同的图像,单击“打开”模式框时,每个模式框中包含不同的信息

这是

如果你有人能帮我解决这个问题,我将不胜感激

谢谢

这是HTML:

<div id="myBtn">
  <div class="container-team">
    <img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/image-normal.jpg" class="image-person">
    <img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/image-hover.jpg" class="overlay-person">
    <div class="centered">Jack Denton</div>
  </div>
</div>


<!-- The Modal -->
<div id="myModal" class="modal">
  <div class="modal-content">
    <span class="close">×</span>
    <aside>
      <div class="photo-person-modal-box">
        <img src="https://i.stack.imgur.com/7UL6j.jpg">
      </div>

      <div class="connect-modal-box">
        <div class="social-icon-modal-box">
          <div class="container-social-icon">
            <a href="mailto:jack.denton@allaboutgroup.org" ><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/email-white.png" width="40px" height="40px" class="icon-normal"></a>
            <a href="mailto:jack.denton@allaboutgroup.org" ><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/email-white-hover-f.png" width="40px" height="40px" class="icon-hover"></a>
          </div>


          <div class="container-social-icon">
            <a href="tel:0203-651-4919"><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/phone-white.png" width="40px" height="40px" class="icon-normal"></a>
            <a href="tel:0203-651-4919"><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/phone-white-hover-f.png" width="40px" height="40px" class="icon-hover"></a>
          </div>


          <div class="container-social-icon">
            <a href="https://www.linkedin.com/in/jackwilliamdenton/" target="blank"><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/linkedin-white.png" width="40px" height="40px" class="icon-normal"></a>
            <a href="https://www.linkedin.com/in/jackwilliamdenton/" target="blank"><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/linkedin-white-hover-f.png" width="40px" height="40px"  class="icon-hover"></a>
          </div>


          <div class="container-social-icon">
            <a href="https://twitter.com/Jack_AAG" target="blank"><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/twitter-white.png" width="40px" height="40px" class="icon-normal"></a>
            <a href="https://twitter.com/Jack_AAG" target="blank"><img src="http://allaboutgroup.isabelsaez.co.uk/wp-content/uploads/2017/09/twitter-white-hover-f.png" width="40px" height="40px"  class="icon-hover"></a>
          </div>

        </div>
      </div>
    </aside>

    <div class="description-modal-box">
      <header class="header-modal-box">
        <div class="name-modal-box">
          <strong>JACK DENTON</strong>
        </div>
        <div class="role-modal-box"> CO-FOUNDER</div>
      </header>

      <div class="content-modal-box">
        <div class="quote-modal-box">The big dog, the raconteur, the linguaphile.
        </div>
        <div class="question-modal-box">Worst job after graduating?</div>
        <div class="text-modal-box">Working on a chicken farm. Have you seen Napoleon Dynamite? It’s like that but worse. Dead chickens in bins a metre from where I was working, stifling heat and constant attacks from angry cockerels. It was alright, though, because they were paying me £3 an hour.
        </div>
      </div>
    </div>
  </div>
</div>

我认为你需要像上课一样使用myBtn

<div class="myBtn"> 


…我想你需要像上课一样使用myBtn

<div class="myBtn"> 


您能描述一下您试图解决遇到的问题的方法吗?您将按钮id分配给所有
myBtn
。id应该是唯一的,而不是与站点相同的。只有最后一个Div具有附加事件的id。我给了所有其他部门相同的身份证,它起了作用。顺便说一句,如果您想要一个公共标识符,您应该使用类而不是ID。class=“myBtn”在所有divsthank上,它现在可以工作了。我对每个ID都有不同的命名。首先,我更改了一个类的ID,但由于某种原因,我不知道模态框不起作用。但是命名每个元素ID有帮助您可以描述您试图解决遇到的问题的方法吗?您可以将按钮ID分配给所有
myBtn
。id应该是唯一的,而不是与站点相同的。只有最后一个Div具有附加事件的id。我给了所有其他部门相同的身份证,它起了作用。顺便说一句,如果您想要一个公共标识符,您应该使用类而不是ID。class=“myBtn”在所有divsthank上,它现在可以工作了。我对每个ID都有不同的命名。首先,我更改了一个类的ID,但由于某种原因,我不知道模态框不起作用。但是命名每个元素ID有帮助
<div class="myBtn">