I have an event list item onclick. It works in Chrome and Internet Explorer, but not in Firefox. Any suggestions?
onclick
<li onclick="alert('test');">test test<br></li>
This works great for me in Firefox.
Check this:
JavaScript is enabled in your browser.
Try adding instructions return false;to your tag.
return false;
Or a function like this:
function test() { //your code here return false; }
<a href="#" onclick="alert('hi');">Link</a>
or
<a href="javascript:void(0)" onclick="alert('hi');">Link</a>
I tried to minimize my html code in order to send the full code to simulate an error, as requested by Boris Zbarsky. Then I found my mistake.
I used the marquee shortcut, which is deprecated. Now I will use jQuery instead.
thank
In Firefox, the event object is not global. You should access it in script tags, not in html.
onclick works like this
<li id="alert">test<br></li> <script> document.getElementById("alert").addEventListener("click", function( event ) { alert('test'); }, false); </script>
Attributes can be ignored by Firefox when it receives invalid HTML, use https://validator.w3.org/ to clear the HTML.