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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:08:15+00:00 2026-05-18T05:08:15+00:00

I have a stylesheet which defines default width for images. When I read the

  • 0

I have a stylesheet which defines default width for images. When I read the image width style with jQuery width() it returns the right width. It also returns the same width when I call css("width"). But if there is no width defined in the stylesheet the function css("width") will also return the computed width() value but won’t say undefined or auto or something like that.

Any ideas how I could find out if style is or is not defined in the CSS code?

Solution works for me cross browser. Thanks to everyone for helping:

$(this).addClass("default_width_check");
var width = ($(this).width() == 12345) ? 'none-defined' : $(this).width();
var height = ($(this).height() == 12345) ? 'none-defined' : $(this).height();
$(this).removeClass("default_width_check");

.default_width_check {
    width: 12345;
}
  • 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-18T05:08:15+00:00Added an answer on May 18, 2026 at 5:08 am

    I have a workaround idea that might work.

    Define a class named default_width before all other style sheets:

    .default_width { width: 1787px }  
    /* An arbitrary value unlikely to be an image's width, but not too large
       in case the browser reserves memory for it */
    

    to find out whether an image has a width set:

    • Clone it in jQuery: element = $("#img").clone()

    • give the cloned element the default_width class: element.addClass("default_width")

    • If its width is 1787px, it has no width set – or, of course, is natively 1787px wide, which is the only case in which this method will not work.

    I’m not entirely sure whether this will work, but it might. Edit: As @bobince points out in the comments, you will need to insert the element into the DOM for all classes to be applied correctly, in order to make a correct width calculation.

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

Sidebar

Related Questions

I have a 'Core.css' which defines a page background image, along with the theme,
We have a large ASP.Net website that has a single css stylesheet which is
I have a Java servlet which generates XML, translates it with an XSLT stylesheet,
In a stylesheet i have: * HTML BODY { padding-right: 0px; padding-left: 0px; padding-bottom:
How can I get superscript done, only in CSS? I have a stylesheet where
I have a xslt stylesheet with multiple xsl:import s and I want to merge
I have an external stylesheet that has specific IE-hacks. Every so often my site
I would like to have alternate behavior during a print stylesheet on a web
I want yo use the EXSLT - DYN:EVALUATE in a style sheet. I have
I have a simple python, in which i have defined styledoc as follows styledoc

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.