I'll explain myself: I'm building a simple web, and at some point in the HTML I have this
<button id="choose" type="button" onclick="choose()">Choose</button>
In the <head> I added a script file so it knows where to find the choose() function
<script src="scripts.js"></script>
And lastly in that scripts.js file I defined the next function:
function choose() {
choices = document.getElementById("choices");
console.log(choices)
}
Now here it comes the problem. When I click the button, in the console I get an "Uncaught TypeError: choose is not a function", but just by deleting for example the last "e" in the function name it works perfectly.
I don't mind at all changing the name, but I'm really curious of what's happening.
Edit: some people are focusing on the "choices" element that isn't seen in the code I provided, but that's not he problem (in fact just by changing the name of the function it works). Anyway, here is the complete body code:
<body>
<form>
Introduce one element in each line:<br/>
<textarea id="choices" rows="10" cols="70"></textarea><br/><br/>
<button id="choose" type="button" onclick="choose()">Choose</button>
</form>
<div id="result"></div>
</body>
And by the way, for me it happens in Firefox too.