Skip to main content

Bug Tracker

Side navigation

#6044 closed bug (duplicate)

Opened February 06, 2010 04:20PM UTC

Closed October 07, 2010 10:00PM UTC

Last modified March 13, 2012 11:56PM UTC

$("selector[style='value']", context) does not work

Reported by: jide Owned by: john
Priority: undecided Milestone: 1.4.2
Component: selector Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:
Description

See the following code :

<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.1EN" "http:www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html>

<head>

<title>Test jQuery</title>

<style type="text/css">

</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>

<script type="text/javascript">

$(document).ready(function() {

var container = $('#container');

Works :

console.log($("div[style='font-size:2em']").html());

Does not work :

console.log($("div[style='font-size:2em']", container).html());

});

</script>

</head>

<body>

<div id="container">

<div style="font-size:2em">

A test div.

</div>

</div>

</body>

</html>

Attachments (0)
Change History (8)

Changed February 06, 2010 04:22PM UTC by jide comment:1

Arghh, there is no way to edit the ticket and I forgot code formatting !

Here we go :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
	<head>
		<title>Test jQuery</title>
		<style type="text/css">
		</style>	
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				var container = $('#container');
				// Works :
				console.log($("div[style='font-size:2em']").html());
				// Does not work :
				console.log($("div[style='font-size:2em']", container).html());
			});
		</script>
	</head>
	<body>
		<div id="container">
			<div style="font-size:2em">
				A test div.
			</div>
		</div>
	</body>
</html>

Changed February 06, 2010 04:35PM UTC by jide comment:2

Hmmm, this is a better example :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
	<head>
		<title>Test jQuery</title>
		<style type="text/css">
		</style>	
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				var container = $('#container');
				// Works :
				console.log($("div[style*='background']").html());
				// Does not work :
				console.log($("div[style*='background']", container).html());
			});
		</script>
	</head>
	<body>
		<div id="container">
			<div style="background:red" class="mydiv">
				A test div.
			</div>
		</div>
	</body>
</html>

Changed February 06, 2010 04:47PM UTC by john comment:3

component: ajaxselector
owner: → john
status: newassigned
summary: $("selector[attr='value']", context) does not work$("selector[style='value']", context) does not work

Changed August 12, 2010 12:12PM UTC by jide comment:4

I found a way to fix this :

Edit Sizzle.selectors.filter.ATTR (line 3273 in jquery v1.4.2), and change line 3277 :

elem[ name ] != null && name != 'style' ?

This will treat the style attribute as a regular attribute.

Changed August 12, 2010 04:10PM UTC by jide comment:5

I committed this fix on my github fork and made a pull request.

Changed October 07, 2010 10:00PM UTC by snover comment:6

priority: → undecided
resolution: → duplicate
status: assignedclosed

Duplicate of #3399.

Changed March 22, 2011 08:05AM UTC by anonymous comment:8

<a href="http://www.charmforbracelets.com">charm for bracelets</a>delicate and high-profile in its own way. All of these ornaments manifest a postmodernism pattern and brought us strong visual shock impact.Also you can change your cloth a<a href="http://www.charmforbracelets.com">charms for links of London</a>clothe pattern. <a href="http://www.charmforbracelets.com">charm for bracelets</a>