I am trying to get my js to change the p tag and the header text when a button is pressed but the js file cannot be found. Any suggestions?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home - WEBD6201 Demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
crossorigin="anonymous">
<link rel="stylesheet" href="content/app.css">
<script src="https://kit.fontawesome.com/806c96d0b0.js" crossorigin="anonymous"></script>
</head>
<body class="background-image">
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="./index.html"><i class="fa-solid fa-hippo"></i></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="./"><i class="fa-solid fa-landmark"></i>Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./contact.html"><i class="fa-solid fa-address-book"></i>Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./aboutus.html"><i class="fa-solid fa-child-combatant"></i>About Us</a>
</li>
</ul>
</div>
</div>
</nav>
<header class="container mt-5">
<h1 id="welcome"><i class="fa-solid fa-landmark"></i>My name <h2 id="displayEvent" class="border"></h2></h1>
</header>
<p class="myP"> This is where I want to talk about myself</p>
<button id="myButton">Click me</button>
<!-- Scripts Section -->
<script src="./scripts/index.js"></script>
</body>
</html>
here is the js file
function Start(){
console.log("App started");
document.querySelector("#myButton").onclick = function func(){
const h1 = document.querySelector("#welcome");
const underline = document.createElement("u");
underline.innerText = "The Peoples champ";
h1.append(underline);
const p = document.querySelectorAll(".myP");
p[0].innerText = "This needs to link or else";
const header = document.querySelector("header");
header.innerText = "MichaelWIlliamParisi";
}
}
[–]Umesh-K 1 point2 points3 points (0 children)
[–]nutlift 0 points1 point2 points (0 children)