Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:53:51+00:00 2026-05-26T07:53:51+00:00

I know how to select elements by attribute like this: <input value=myvalue /> $(‘input[value=myvalue]’)

  • 0

I know how to select elements by attribute like this:

<input value="myvalue" />
$('input[value="myvalue"]')

But how it is possible to select dom elements with specified css rules set.
For example i need to select all elements with css “background-position” set;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:53:52+00:00Added an answer on May 26, 2026 at 7:53 am

    There doesn’t appear to be a jQuery selector for this, but you could use a .filter() to reduce a selector to suit your needs:

    $('div').filter(function() {
        return ($(this).css('backgroundPosition')); // tests for existence
    });
    

    However, the problem here is that even if ‘background-position’ isn’t set, some browsers set it to default values. You’ll have to compare against those default values, but you won’t be able to tell if those values were explicitly set in a stylesheet or not.

    (Update: IE8 returns $(this).css('backgroundPosition') as “undefined” no matter what. The workaround is to test for ‘backgroundPositionX’ and/or ‘backgroundPositionY’ individually. However, while the defaults should be “0%”, IE8 reports a default of “0px” instead. Test for both.)

    (Update 2: Firefox doesn’t return individual properties, only combined ‘background-position’; IE8 doesn’t return combined, only individual. Webkit will do both.)

    $('div').filter(function() {
       return ($(this).css('backgroundPosition') !== "0% 0%" // firefox, webkit
            && $(this).css('backgroundPositionX') !== "0px"  // ie8
            && $(this).css('backgroundPositionY') !== "0px");
    });
    

    http://jsfiddle.net/mblase75/s8dx2/23/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know it's generally a bad idea to do queries like this: SELECT *
I have several html input elements which all look something like this: <input id=1
jQuery has wonderful selectors for DOM elements, but can you 'select' an event object.
I'm trying to select all input elements on a page, but not the ones
I would like to know how can I use jQuery to select multiple items
I have XML like this: <assessment> <variables> <variable> <attributes> <variable_name value=FRED/> </attributes> </variable> </variables>
I need to select a node with a id attribute that I only know
I google it up but didn' find something like this. I am having an
When I include an 'onClick' attribute in setInnerXTHML() like this: var innerHtml = '<span>Build
As you most likely already know, it's simple in JQuery to select all elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.