Skip to main content

Bug Tracker

Side navigation

#13772 closed bug (invalid)

Opened April 13, 2013 04:51AM UTC

Closed April 29, 2013 08:32AM UTC

:target selector works only after document is ready

Reported by: GolubevS79@gmail.com Owned by: GolubevS79@gmail.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

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

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

    $(document).ready(function(){
        console.log($(":target").length); // returns 1
    });
</script>
Attachments (0)
Change History (6)

Changed April 13, 2013 05:06AM UTC by GolubevS79@gmail.com comment:1

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

Changed April 13, 2013 05:14AM UTC by rwaldron comment:2

owner: → GolubevS79@gmail.com
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:

Changed April 13, 2013 06:21AM UTC by GolubevS79@gmail.com comment:3

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

Changed April 13, 2013 12:27PM UTC by gibson042 comment:4

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.

Changed April 14, 2013 11:03PM UTC by m_gol comment:5

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.

Changed April 29, 2013 08:32AM UTC by trac-o-bot comment:6

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!