Skip to main content

Bug Tracker

Side navigation

#14135 closed bug (patchwelcome)

Opened July 15, 2013 07:39PM UTC

Closed July 15, 2013 11:51PM UTC

:target selector does not work with .ready in Chrome

Reported by: Owned by:
Priority: low Milestone: None
Component: selector Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Create following HTML file. Open it in Chrome and any other browser and append hashtag #foo to the file name


In Chrome, text will be blue (no class appended to #foo)

In other browsers it will be red (#foo has class bar)

		.bar {
			color: red !important;
		:target {
			color: blue;
	<div id="foo">Hello, world</div>
	<script src=""></script>
		$(function() {

When executed from console, $(":target").addClass("bar") works

Attachments (0)
Change History (5)

Changed July 15, 2013 07:46PM UTC by rwaldron comment:1

#14136 is a duplicate of this ticket.

Changed July 15, 2013 08:30PM UTC by comment:2

Looks like in Chrome only it will work with $(window).load, but not with $(document).ready

Changed July 15, 2013 08:39PM UTC by dmethvin comment:3

Seems like this is a cantfix limitation unless someone has some ideas for fixing it.

Perhaps a related or duplicate of the bug here:

Changed July 15, 2013 08:56PM UTC by comment:4

Changed July 15, 2013 11:51PM UTC by timmywil comment:5

component: unfiledselector
priority: undecidedlow
resolution: → patchwelcome
status: newclosed

We could defer to Sizzle in Chrome, but we'd need a support test, and I'd be suspicious of a support test involving urls. I'd welcome a patch that could implement a feature test that didn't conflict with page scrolling, pushState history, etc.