I recently wanted to test something, so I wrote a function into elements tab and a simple anchor tag to call that JS function. For some reason, I always get the ReferenceError saying the function is not defined. All I did was open console, type the function between the script tags, and write the anchor tag to click on.
<script type="text/javascript">
function showResult() {
var num = 5 * 5;
alert( num );
}
</script>
<a onclick="showResult()">Click</a>
It tried to call the showResult() function but I get the ReferenceError every time. However, I put this into an HTML file and opened it up in Chrome and it worked as expected. Does anyone know why I cant write a JS function into the browser and execute it?