Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140248

Why isn't a class being added to a loaded nav element?

$
0
0
this.loadTemplate = async(currentPage) => {
  let promise = new Promise((resolve) => {
    $(() => $("#nav").load("./nav.html"));
    $(() => $("#footer").load("./footer.html"));
    resolve("resolved");
  });

  let result = await promise;
  console.log(result);
  $(`#${currentPage}`).addClass("current-page");
};

Above is the code for loading and adding the class to the nav.html file. Which should change an element to orange. Which it doesn't.

Any help is appreciated.


Viewing all articles
Browse latest Browse all 140248


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>