Hi,
I just started learning JavaScript and HTML. I'm trying to make a message appear in the span with ID "message" when a button is clicked two different ways, first using JavaScript and also using jQuery. However, neither is working for me. Here is the JavaScript:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>First Page</title>
<script>
document.getElementById("click_here").addEventListener(click, function() {
document.getElementByID("message").innerText = "Hello";
});
</script>
</head>
<body id="main">
<input name="click_here" id="click_here" type="button" value="click"/>
<p>This is the message: <span id="message"> </span></p>
</body>
</html>
And the jQuery version:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>First Page</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
$("#click_here").click(function() {
$("#message").val("Hello!");
});
</script>
</head>
<body id="main">
<input name="click_here" id="click_here" type="button" value="click"/>
<p>This is the message: <span id="message"> </span></p>
</body>
</html>
Can anyone tell me what I'm doing wrong? Thanks!!