I\’ve been trying to figure this out for hours now and I can\’t understand why my javascript isn\’t working. I have a select button like this
<select onclick=\"populateList()\">
<option>1</option>
<option>2</option>
</select>
My Javascript is in the same folder and is linked as:
<script src=\"script.js\"></script>
In that file, the function is so simple. Just:
function populateList() {
console.log(\"Test\");
}
And it won\’t work. Any ideas as to why?
EDIT:
I\’ve tried doing the onchange, onchange(), onclick, onclick(), onClick(), ect. and still nothing.
Edit2:I didn\’t change a thing but it started working. Thank you all. Much love.
Edit 3: Nevermind. I\’ve determined at least that it works when the script is directly in the html but not when it\’s in script.js





Rating:
The post javascript – select onclick onchange not working appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/javascript-select-onclick-onchange-not-working.html
No comments:
Post a Comment