I have some simple javascript functions:
function focus(id) { var e = document.getElementById(id); if (e != null) { e.focus(); } } function show(id) { var e = document.getElementById(id); if (e != null) { e.style.display = "inline"; } }
Then I have an html tag with an onclick event.
<a title="Click This" onclick="focus('some_textbox'); show('some_panel');">Click This</a>
When I click the "Click this link" link, only the show () method is executed. For some reason, the focus method is never called. Any idea why this is happening?
I tried to clear my cache and reordered the focus () and show () methods. I also confirmed that everything is spelled correctly.
Is it because focus () is already a function inside javascript?
Edit: I tried to rename the function to focus2, and now it works. Very strange. Does anyone know why this is happening?
source share