debugging - How to highlight Javascript missing brackets calling function -


in following html/javascript snippet, i'm missing function's brackets in onclick statement (it should read: onclick="showmessage()").

how missing brackets highlighted

(a) in notepad before display page.

(b) in browser js console after display page?

if not possible besides inspection, there way identify issue more easily?

<html> <head>     <script>         function showmessage() {             document.getelementbyid("messagearea").innerhtml = "hello world";         }     </script> </head> <body>     <input type="button" value="show message" onclick="showmessage">     <div id="messagearea">---</div> </body> </html> 

the problem onclick takes kind of javascript expression, function execution being 1 of them. example:

<script>      var = 10  </script>    <!--all valid , don't throw errors -->    <button onclick="a">nothing happens</button>   <button onclick="a++">increment</button>   <button onclick="alert(a)">check value</button>  <button onclick="undefined">surely not?</button>

executing functions showmessage() 1 of it's primary use. , technically it's not error have showmessage without () inside onclick. showmesage function definition, if type showmessage , press enter in browser's console, return function definition , won't throw error. ides don't underline error because it's not error.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -