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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:10:07+00:00 2026-06-14T00:10:07+00:00

I have the following element. var e=$(‘<span/>’, {class:’someClass’,text:’Hello’}); I wish to get its outer

  • 0

I have the following element.

var e=$('<span/>', {"class":'someClass',text:'Hello'});

I wish to get its outer width. It appears that I cannot just use e.outerWidth() as it needs to be written to the screen first. Correct?

So, now the real question. Instead of using text “Hello”, I wish to know the outer width if the text had been “Goodby” How would this be accomplished?

Thank you

  • 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-06-14T00:10:08+00:00Added an answer on June 14, 2026 at 12:10 am

    You could append the element to the document but outside the viewport, eg left: -10000px. Then outerWidth() would work.

    Try this:

    var e = $('<span/>', {"class":'someClass',text:'Hello'}).css({
        'position': 'absolute',
        'left': '-10000px'
    }).appendTo('body');
    var outerWidth = e.outerWidth();
    e.remove(); // remove the element from the DOM once we've got it's width
    

    Example fiddle

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

Sidebar

Related Questions

I have following html: <div id=note> <textarea id=textid class=textclass>Text</textarea> </div> How can I get
I have the following class public class Element { public List<int> Ints { get;private
I have the following: $(document).ready(function() { var myIframe = document.getElementById('myIframe'); var element = myIframe.contentDocument.createElement('script');
I have the following click event $(.element).click(function() { var idNum = $(this).getID; $('#new-'+idNum).fadeIn(); });
I have the following element selected: >>> order <Element Order at 0x10364b960> To get
Say I have the following element: <p id=thingy>Here is some <em>emphasized</em> text!</p> In a
I have following selectors: var $foo = $('.someClass'); var $rows = $('.rows'); $rows.each(function (index,
I have the following code: var div = $(<div id='3.5'>AA</div>); div_id_after = Math.floor(parseFloat(div.get(0).id)); $('#'+div_id_after).after(div);
Hello I have a following formvalidatior function in my document. function formValidator(formid) { var
I have the following $(element).click(function() { var foo=bar; if ( foo == bar )

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.