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 6104651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:51:57+00:00 2026-05-23T13:51:57+00:00

I have a situation where I am setting up a mobile theme for a

  • 0

I have a situation where I am setting up a mobile theme for a wordpress website.
Now what I would like to do is, grab any elements (p, divs, etcc) within the “#content” div, and apply css “width: 100%” to each of those child elements.

The reason I want to this is, in event somebody sets a fixed width for a div, I need it to overwrite that and revert it to 100% so it does not get cutoff when viewing on a mobile device with a smaller screen.

I would like to know how this can be achieved using Jquery.

I appreciate any help with this.
Thanks

  • 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-23T13:51:58+00:00Added an answer on May 23, 2026 at 1:51 pm

    Sometimes, jQuery is the wrong way…

    You shouldn’t use jQuery unless it’s offers a legitimate advantage. Often times using standard JavaScript will give you enormous performance advantages. With your situation, you could do something like the following:

    var i,
        tags = document.getElementById("content").getElementsByTagName("*"),
        total = tags.length;
    for ( i = 0; i < total; i++ ) {
      tags[i].style.width = '100%';
    }
    

    Online Demo: http://jsbin.com/otunam/3/edit

    That being said, the jQuery method is pretty simple as well.

    $('#content').find('*').width('100%');
    

    This will run down into each level of #content, affecting all elements.

    Online Demo: http://jsbin.com/otunam/edit

    Performance Differences

    Using http://jsperf.com to compare the peformance difference here we can see the magnitude of speed raw JavaScript has over the jQuery alternative. In one test JavaScript was able to complete 300k operations in the time it took jQuery to complete 20k.

    Test Now: http://jsperf.com/resizing-children

    But, Why JavaScript?

    Ultimately the question of whether jQuery or Raw JavaScript is better is a red-herring, distracting from the real question – why use scripting at all? If you detect a mobile browser, load a new stylesheet containing mobile rules:

    #content * { width:100% }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have situation like this: class IData { virtual void get() = 0; virtual
I have situation like this: user submits form with action='/pay' in '/pay' I have
I have an unavoidable situation that looks like this (simplified): FUNCTION_TO_CALL = y #
I have a situation where on a dev server I'd like to pull from
I have a situation where I'd like to keep a history or log of
In this situation how would I get the setting to keep the hovered state
I have situation, where running a query that filters by an indexed column in
I have situation in which I read a record from a database. And if
I have situation where I need to change the order of the columns/adding new
I have situation where a user can manipulate a large set of data (presented

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.