Opened 9 years ago
Closed 9 years ago
#14761 closed bug (notabug)
.click() event does not work correctly in Firefox
Reported by: | Redsandro | Owned by: | Redsandro |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.11.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
On a selected virtual anchor element, .click() fires a click event in Chromium. This is correct.
In Firefox however, it does not. You need to manually create a click mouseEvent.
I've created this jsfiddle to explain exactly what I mean:
Change History (5)
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
Owner: | set to Redsandro |
---|---|
Status: | new → pending |
It works if you append to the body: http://jsfiddle.net/D572L/2/
Is there a reason to not append the link to the body? In general, detached DOM often has issues.
comment:3 Changed 9 years ago by
In the fiddle you don't even use jQuery!
In this line
$(anchor)[0].click();
you access the native element via [0] and try to trigger the native click event.
comment:4 Changed 9 years ago by
Status: | pending → new |
---|
@dmethvin Is there a reason to not append the link to the body?
Just want to offer some client side text as a download. There is no semantic purpose for the anchor in the Document/DOM. This seems like logical thing to do. I don't need to end up with a bunch of irrelevant elements in my DOM like empty soda cans polluting the street.
Either way, thanks for the workaround. I guess it's human nature to leave trash behind. ;) But still, I think that jQuery should be able to handle this in the way I proposed.
@anonymous $(anchor).click(); doesn't work either.
comment:5 Changed 9 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
Regardless, this isn't a jQuery bug. This is how the browser behaves.
(I was meaning to file this under Events but I cannot seem to edit that.)