I'm new to javascript. My chrome extension currently is not printing text into the little window once the button is clicked.
The first bit is the popup.js and the second is popup.html. My goal is force once you click the button, the area where it says filler is replaced with the text I have set in popup.js. I don't know javascript well and this is a lot of code that I have compiled from around. Thanks everyone!
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("click-this").addEventListener("click", handler;
});
// The handler also must go in a .js file
var date = new Date();
var dayOfWeek = date.getDay();
function handler() {
if (dayOfWeek == 0){
return "sunday";
}
else if (dayOfWeek == 1){
return "monday";
}
else if (dayOfWeek == 2){
return "tuesday";
}
else if (dayOfWeek == 3){
return "wednesday";
}
else if (dayOfWeek == 4){
return "thursday";
}
else if (dayOfWeek == 5){
return "friday";
}
else if (dayOfWeek == 6){
return "saturday";
}
}
<head>
<script src="popup.js"></script>
</head>
<div class="row">
<div class="column large-6 medium-6 small-12">
<h1> Lunch Menu </h1>
<p> filler filler filler</p>
<button type="button" id="click-this">Click</button>
</div>
</div>
<style scoped>
div {
height: 100px;
width: 500px;
}
</style>