Skip to main content

Bug Tracker

Side navigation

#4068 closed bug (duplicate)

Opened February 04, 2009 07:17PM UTC

Closed October 07, 2010 10:00PM UTC

Last modified March 15, 2012 02:07PM UTC

Attribute filtering does not work for style attribute

Reported by: bgrinstead Owned by: john
Priority: major Milestone: 1.3.2
Component: selector Version: 1.3.1
Keywords: selector attribute filter Cc:
Blocked by: Blocking:
Description

I noticed that jQuery was not selecting elements when attempting to filter based on the style attribute. It works fine for others, like 'name', just not 'style'.

Here is an example:

    <span style="font-weight:bold;">This is bold</span>
    <span style="font-style:italic;">This is italic</span>
    <span style="text-decoration:underline;">This is underlined</span>
    <span name="thisworks">This IS selected by the attribute filter</span>


    <script type="text/javascript">
    $(function() {
            alert($("span[style*='bold']").length);
            alert($("span[style^='font-style']").length);
            alert($("span[style$='underline']").length);
            alert($("span[name*='works']").length);
    });
    </script>

Thanks!

Attachments (0)
Change History (4)

Changed February 08, 2009 07:05PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

The

style
attribute does not return a string. You would need to match the
style.cssText
css property, so the attribute selector syntax isn't the droid you're looking for. I think there is a plugin floating around that adds
:css(property='value')
to the selector syntax but I couldn't find it. This plugin would seem to do the job as well, but with a different syntax:

http://plugins.jquery.com/project/EnhancedAttributeSelectors

Changed February 08, 2009 07:25PM UTC by dmethvin comment:2

I should say the

style
*property*, see #3399 for more discussion.

Changed February 08, 2009 07:44PM UTC by dmethvin comment:3

resolution: invalid
status: closedreopened

I'm going to reopen this because it looks like it might be a regression due to the integration of Sizzle.

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

resolution: → duplicate
status: reopenedclosed

Duplicate of #3399.