I have a function written in JavaScript. The function is correct, I cannot change it. I need to write HTML code to handle it. Unfortunately, I do not fully understand how it works, when starting the debugger it screams errors:
function A2(params) {
if ((params / (10 % 4)) === 132.993) {
var m = document.querySelector("Math");
console.log("A2 hip hip hura");
m.innerHTML = "Set Text In Here :";
var arr = [m];
arr.push("Element");
arr.push("Second Element");
m.addEventListener("click", A2(arr));
}
}
<div id="Math">
<input type="text" value="nothing" />
</div>
<input type="submit" value="SEND" onclick="A2(265.986)" />
error:
TypeError: Cannot set properties of null (setting 'innerHTML')
var m = document.querySelector("#Math");(note the#which refer to an id)m.addEventListener("click", A2(arr));won't work, nothing will happen whenmis clicked, sinceA2doesn't return a function.