JQuery.load () opens a script in a new tab

I have jQuery code that loads in an HTML file that includes a script. The problem is that the script opens in a new tab, instead displays in its own divwhere it should be.

Script that loads the contact into:

$(document).ready(function(){
     $('#cont').click(function(event){
    event.preventDefault();
        $("#content").hide();
        $('#home').removeClass("active");
        $('#info').removeClass("active");
        $('#vergun').removeClass("active");
        $('#pasp').removeClass("active");
        $('#cont').addClass("active");
        $("#content").show();
        $("#content").load("contact.html"); 
      });
});

contact.html

 <div id="contents">
    <h2>Adres</h2>
      <table>
        <tr>
          <td id="tableSpacer"><i class="fa fa-phone"></i></td><td id="tableSpacer"><a href="tel:734-389-7473">734-389-7473</a></td>
        </tr>
        <tr>
          <td rowspan="2"><i class="fa fa-globe"></i></td><td>25 Woodland Drive </td>
        </tr>  
        <tr>
          <td colspan="2" >28803 Megaton, Commonwealth</td>
        </tr>
        <tr >
          <td id="tableSpacerTop"><i class="fa fa-envelope"></i></td><td id="tableSpacerTop">info@megaton.nl</td>
        </tr>
      </table>
        <div id="contentMail">
          <script type="text/javascript" src="/mail/script/mail.js"></script>
        </div>
  </div>

Code where it is loaded into

<center>
    <div id="content" style="position: static;">
        <div id="contents"></div>
    </div>
</center>

The code that runs the script

<a class="menuItem" id="cont" href="#">Contact</a>

How it should look What should it look like

What's happening what's happening

Does anyone have a solution for this? Thanks in advance.

+4
source share
1 answer

Your mail.js file has the following questions: you are using document.write ( instead of $ ('# contents'). Html (

, . . 37 mail.js.

0

Source: https://habr.com/ru/post/1620521/


All Articles