Bug Tracker

Opened 10 years ago

Closed 10 years ago

#13772 closed bug (invalid)

:target selector works only after document is ready

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


I'm not sure this is bug (may be it's documentation issue) but ":target" selector works only in .ready() handler, i.e.

    console.log($(":target").length); // returns 0

        console.log($(":target").length); // returns 1

Change History (6)

comment:1 Changed 10 years ago by [email protected]

In this example, the target element already existed at the time of the script (i.e. <script> is the last element on the page)

comment:2 Changed 10 years ago by Rick Waldron

Owner: set to [email protected]
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists—you may need to change this to a specific version depending on the test case.

To get you started, use the appropriate boilerplate:

Open the link and click to "Fork" (in the top menu) to begin.

Also, please read:

Additional resources:

comment:3 Changed 10 years ago by [email protected]

Status: pendingnew

Sorry guys, but as to jsFiddle the example requires hash fragment in page URL (it is possible to set "window.location.hash" property in the script, but the example works different in this case).

I've tested on the 2.x (edge) version and good results was obtained only in IE10.

If jsFiddle is absolutely necessary let's close the ticket

comment:4 Changed 10 years ago by gibson042

Status: newpending

You can create a jsFiddle and access it directly by appending "/embedded/result/" to the URL or you can link to a demonstration page somewhere else, but we do need reproducible test cases in order to analyze and fix bugs.

comment:5 Changed 10 years ago by m_gol

Actually, appending /embedded/result/ doesn't help as it still adds a jsFiddle banner at the top and puts the test URL into an iframe. Appending /show/light/ works, though.

comment:6 Changed 10 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.