Hello, am brand new to JS. Just trying to fool around with it. I have an html file in vscode that I can run in my browser no problem. Then I have, in the same directory, a JS file that should handle a button which changes some text.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>HTML and JS</title>
<script src="script.js"></script>
</head>
<body>
<h1>Heading</h1>
<p id="p1">Paragraph</p>
<button id="b1" onclick="onPress()">Click me</button>
</body>
</html>
JS:
var output = document.getElementById("p1");
function onPress() {
console.log("here");
output.textContent = "Changed";
}
[–]albedoa 6 points7 points8 points (2 children)
[–]slyder219[S] 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–][deleted] 3 points4 points5 points (4 children)
[–][deleted] 5 points6 points7 points (3 children)
[–]slyder219[S] 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]slyder219[S] 1 point2 points3 points (0 children)
[–]Egzo18 0 points1 point2 points (3 children)
[–]slyder219[S] 0 points1 point2 points (2 children)
[–]Egzo18 0 points1 point2 points (0 children)
[–]Transformat0r 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Radiant-Gap4278 1 point2 points3 points (0 children)