Opened 10 years ago
Closed 10 years ago
#13772 closed bug (invalid)
:target selector works only after document is ready
Reported by: | Owned by: | ||
---|---|---|---|
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>
Change History (6)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
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:
- jQuery 1.x http://jsfiddle.net/FrKyN/
- jQuery 2.x http://jsfiddle.net/VUp3e/
Open the link and click to "Fork" (in the top menu) to begin.
Also, please read:
- http://blog.jquery.com/2013/03/01/jquery-2-0-beta-2-released/
- http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/
Additional resources:
- Won't Fix: http://contribute.jquery.org/wont-fix/
- CLA: http://contribute.jquery.org/CLA/
- Style Guide: http://contribute.jquery.org/style-guide/js/
comment:3 Changed 10 years ago by
Status: | pending → new |
---|
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
Status: | new → pending |
---|
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
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
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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!
In this example, the target element already existed at the time of the script (i.e. <script> is the last element on the page)