Reputation: 20492
Using jQuery, I have attached a "click" event handler to some "li" HTML elements.
The problem is: when I click the "li" element, the event does not fire.
"How?" - will you ask... so, see it by yourself in this simple jsFiddle
Consider:
float: left
style from the "li" element, or the position: relative
style from the "form", then the problem disappears!So, I am not exactly asking how to circumvent or workaround the problem, I am asking why the "click" event does not fire. Is this a bug? A bug from what? Browser? jQuery? CSS? It simply does not make sense to me, and I will love to see an explanation!
Thanks.
Upvotes: 1
Views: 2795
Reputation: 539
I have created a fiddle for you please have a look at itclick action working fine on all elements
Upvotes: 0
Reputation: 33
The reason why click function is not working is li element are not placed inside form
Upvotes: 0
Reputation: 1062
If you inspect your DOM with firebug or something similar you will notice your form is floating over the first elements of your ul, therfore it works on "image" because it is not hidden by your form. Try to empty your css code in jsFiddle and everything will be working as intended.
Upvotes: 1
Reputation: 667
Because the li
's do float and the form has a position:relative
, the form lies above the li
's, therefore you can still click "Image"
BTW.: If you are using Firebug or Webdeveloper tools you can detect that.
Upvotes: 4