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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:19:23+00:00 2026-06-12T06:19:23+00:00

I have a div which I would like to set custom dimensions using two

  • 0

I have a div which I would like to set custom dimensions using two text inputs.

<div id="theFrame"></div>
    width: <input id="custWidth" type="text">
    height: <input id="custHeight" type="text">
<br>
<button id="custSet">Set my width!</button>

I have tried setting the height and width with variables, but I am at a loss as to how to do it now.

var frame = $('div#theFrame');

$("#custWidth")
    .keyup(function () {
        var custWidth = $(this).attr('value');
    })
    .keyup();

$("#custHeight")
    .keyup(function () {
        var custHeight = $(this).attr('value');
    })
    .keyup();

$('#custSet')
    .click( function() {
        frame.css({height: custHeight, width: custWidth});
    });

Thanks.

http://jsfiddle.net/Kyle_Sevenoaks/6MUuv/

  • 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-12T06:19:24+00:00Added an answer on June 12, 2026 at 6:19 am

    You most probably need to include ‘px’ when setting your CSS:

    frame.css({height: custHeight + 'px', width: custWidth + 'px'});
    

    Also, you need to define your custHeight and custWidth parameters globally, since they are local only in the key up function.

    var frame = $('div#theFrame'), custWidth = 0, custHeight = 0;
    
    $("#custWidth")
        .keyup(function () {
            window.custWidth = $(this).attr('value');
        })
        .keyup();
    

    And… I believe you don’t need the second keyup() call there:

    $("#custWidth")
        .keyup(function () {
            window.custWidth = $(this).attr('value');
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div element which I would like to change it'e dir attribute
I have two divs like so <div id=parent style=width:100px:overflow:hidden;> <div id=child> tooooooooooooooooooooo much content
I have a set of div elements. In jQuery , I would like to
I would like to set a random color for the text of a fadeIn/Out
I have a Team to which I would like to add players (objects of
I have some dynamic text contained in a div that is set to whatever
I have a discussions controller for which I would like to have an edit
I would like to have a dialog common to two different call-to-action buttons (row
I have an gallery of images which I would like to be faded out
I have DIV with flexible width set e.g. min-width:800px and max-width:1400px. In this DIV,

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.