I'm new to HTML and javascript, but basically, I'm stuck on trying to get the "Change This" text to change when I click "First Year". It sort of works however it'll reload the page really quickly and say at the top left corner "hi there." enter image description here
Here is my HTML Code:
<head>
<meta charset="UTF-8">
<title>Classes</title>
</head>
<body>
<h1>
Course List
</h1>
<nav>
<ul>
<li><a href = "http://localhost:63342/Resume/Resume.html?_ijt=gpaieus6bdg9b18347umv1b08p"> Home </a></li>
<li><a href = "http://localhost:63342/Resume/Classes.html?_ijt=bv5pcf5ooj4ruaat99jlvgrjm5"> Classes </a></li>
<li><a href = """> Projects </a></li>
<li><a href = ""> About </a></li>
<li><a href = ""> Contact </a></li>
</ul>
</nav>
<div class = "column1">
<p> Classes</p>
<ul>
<li onclick = "getText(this.id)" id = "text1"><a href = "">First Year</a></li>
<li><a href = "">Second Year</a></li>
<li><a href = "">Third Year</a></li>
<li><a href = "">Fourth Year</a></li>
</ul>
</div>
<div class = "column2">
<p>
Change this
</p>
<script
type = "text/javascript" src = "click.js">
</script>
<script
type = "text/javascript" src = "ParagraphChanger.js" >
</script>
</div>
</body>
</html>
CSS code:
<style>
nav ul
{
margin: 30;
padding: 0;
display: flex;
justify-content: space-around;
list-style-type: none;
}
nav li{
display: inline:
margin-right: 40px;
}
h1
{
text-align: center;
}
.column1
{
width: 300px;
height: 825px;
float: left;
margin: 10px;
border: 2px solid #000000;
}
.column2
{
width: 1100px;
height: 825px;
float: left;
margin: 10px;
border: 2px solid #000000;
}
</style>
JavaScript Code (paragraph changer):
function getText(str)
{
document.write('<p2>' + "hi there" + '</p2>');
}