2

I am using jQuery 3.2.1 and this code

// /js/main.js

$(function () {

  var targetId = 'about';

  var container = $('#pages').find('.active').removeClass('active').end()
                             .find('#' + targetId).addClass('active');

  console.log(container, container.load);

  if (!container.data('loaded')) {
    container.load('/pages/' + targetId + '.html');
  }

});

produce this error

Uncaught TypeError: container.load is not a function

The output for container and container.load is

[div#about.tab-pane.active, prevObject: r.fn.init(1)] undefined

I don't understand why I get this error.


Edit

I have no idea why people want the HTML, but here is the relevant part of it

<!DOCTYPE html>
<html lang="en">
  <head>

  </head>
  <body>
    <div class="container">

      <!-- Tab panes -->
      <div id="pages" class="tab-content">
        <div role="tabpanel" class="tab-pane default" id="about"></div>
      </div>

    </div><!-- /.container -->

    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=" crossorigin="anonymous"></script>
    <script src="/js/main.js"></script>
  </body>
</html>
Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214

0 Answers0