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

  • SEARCH
  • Home
  • 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 6068241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:41:40+00:00 2026-05-23T09:41:40+00:00

Using jQuery, how can I say ‘Does a child of #parent have the stlye=width’.

  • 0

Using jQuery, how can I say ‘Does a child of #parent have the stlye=”width”‘.

I know the beginning…

jQuery('#parent').children();

But I dont know how to write has style ‘width’.

EDIT

In the html the div says style=”width=xxx”. I want to find the first occurrence of that width and add a margin: 0 auto; to that div. Its for centering videos.

Some of the divs that say style=”width” are 3 levels nested from the top. That still should work with .children() right?

For some reason, i cant get any of the below codes to work…

  • 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-23T09:41:40+00:00Added an answer on May 23, 2026 at 9:41 am

    You need to use an “attribute contains” selector:

    Description: Selects elements that have the specified attribute with a value containing the a given substring.

    jQuery('#parent [style*="width:"]')
    

    That will give you the children of #parent that have the string width: in their style attribute.

    Example: http://jsfiddle.net/ambiguous/vpdGa/1/

    If you need to worry about border-width and similar CSS properties, then you could add your regular expression selector:

    jQuery.expr[':'].regex = function(elem, index, match) {
        var matchParams = match[3].split(','),
            validLabels = /^(data|css):/,
            attr = {
                method: matchParams[0].match(validLabels) ? 
                            matchParams[0].split(':')[0] : 'attr',
                property: matchParams.shift().replace(validLabels,'')
            },
            regexFlags = 'ig',
            regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
        return regex.test(jQuery(elem)[attr.method](attr.property));
    }
    

    And then search thusly:

    jQuery('#parent :regex(style,(^|\\s)width:)')
    

    Don’t forget the extra backslash to get past the string literal’s backslash interpretation.

    And an example of this approach: http://jsfiddle.net/ambiguous/vpdGa/4/

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

Sidebar

Related Questions

Does anyone know how can I default/focus a button by using jquery? If I
Let's say by using jQuery I can set the width of a DIV doing
Can I send email using jQuery only? I don't have .Net or PHP etc
How can I set the background-image css property of say a div using jquery?
Say I have a mobile web app written using JQuery Mobile, this app retrieves
Bear with me, I'm new to manipulating XML using jQuery. Say I have an
I have a asp.net webapp and I am using Jquery. I wanted to know
Im using jQuery mobile to make a small project. You can say its a
Using jQuery I can easily get the number of DOM elements used by a
Is there a way using JQuery that i can detect when a div starts

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.