Bug Tracker

Opened 11 years ago

Closed 9 years ago

Last modified 8 years ago

#4068 closed bug (duplicate)

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!

Change History (4)

comment:1 Changed 11 years ago by dmethvin

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

comment:2 Changed 11 years ago by dmethvin

I should say the style *property*, see #3399 for more discussion.

comment:3 Changed 11 years ago by dmethvin

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.

comment:4 Changed 9 years ago by snover

Resolution: duplicate
Status: reopenedclosed

Duplicate of #3399.

Note: See TracTickets for help on using tickets.