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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:41:20+00:00 2026-05-14T20:41:20+00:00

I have piece of javascript code, which should process when the browser window is

  • 0

I have piece of javascript code, which should process when the browser window is resized.

resize.style.marginRight=(resize.offsetWidth-$(this)[0].offsetWidth)+'px'

Tryed this stuff (doesn’t work):

window.onresize = function(event) {
resize.style.marginRight=(resize.offsetWidth-$(this)[0].offsetWidth)+'px'
}

Full code available – http://jsbin.com/adelu3/2/ (see page source)

Html (generated by the script):

<div class="resizable-textarea">
    <span>
        <textarea class="resizable processed" cols="" rows=""></textarea>
        <div class="resize"></div>
    </span>
</div>

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-14T20:41:21+00:00Added an answer on May 14, 2026 at 8:41 pm
    $(this)[0].offsetWidth
    

    offsetWidth is a property of elements. In the callback code of window.onresize, this is a Window, which doesn’t have an offsetWidth.

    What is this supposed to be? (The onresize event is not present in the linked code.) If you want to read the window width, use $(window).width().

    If you want to read the width of some other (ancestor?) element that you had as this in the enclosing scope, you must either find that element by looking up from the resize element, or retain a reference to the other element in a closure, eg.:

    var that= this;
    $(window).resize(function() {
        resize.style.marginRight= resize.offsetWidth-that.offsetWidth+'px'
    });
    

    (nb. $(this)[0] does precisely nothing.)

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

Sidebar

Related Questions

I have this piece of Javascript code, which takes about 600 ms on every
I have this piece of Javascript code: N1 = Math.floor(275 * month / 9)
I have a simple piece of Javascript code and I get this Error :
I have this piece of code in javascript: var catId = $.getURLParam(category); In my
I have a piece of JavaScript code which is expected to set an integer
I have been staring myself blind at this piece of javascript code, I need
I have this piece of code: <script language=javascript type=text/jscript> document.write(<img src='http://dm.leadgenesys.com/jpgp.lgt?en=P.........TP_Q=&amp;ur=' + escape(document.referrer) +
I have a piece of code in javascript which calculates something , There is
I have this piece of code written in jQuery and PHP: <script type=text/javascript> $(document).ready(function(){
I have this piece of javascript which is supposed to validate on the clientside.

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.