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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:06:42+00:00 2026-06-03T05:06:42+00:00

I am in a situation I am appending a button to a div, which

  • 0

I am in a situation

I am appending a button to a div, which has a width

  $('#main').append('<button id="hello" type="button" style="width:100px">Click Me!</button>');

I am trying to change the width however nothing happens

$("#main").prop({ width: '300px'});

Ive tried using .css , .attr and .width to try changing the width however the same problem keeps happening. I am still not sure why this is happening even after googling, if anyone can help that would be great.

  • 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-03T05:06:44+00:00Added an answer on June 3, 2026 at 5:06 am

    If you’re trying to set the width of the button, you’ve got to select the button, not the div.

    $('#hello').width(300);
    

    (Demo 1)

    If your goal is to set the width immediately after .append()ing, you’re better off just starting with the right width:

    $('#main').append($('<button/>', {
        id: 'hello',
        text: 'Click Me!',
        width: 300
    }));
    

    (Demo 2)


    Read up on .width(): http://api.jquery.com/width/#width2 (Yes, the jQuery API docs are down right now.)

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

Sidebar

Related Questions

I have very odd situation where I'm appending children (thumbnails) to a div and
Situation: need to find which layer the user has touched. Problem: Apple says we
Situation: I have a database that contains sales records, each record has a ID
Situation: you've got a .swf embedded in an html page, and when you click
I am trying dynamically to append an <svg> element to an existing SVG island
Situation: I am trying to write a efficient query using "LIKE" statement to look
Scenario: I have a main Latex file (main.tex) in which I include a subfile
I have a situation where I'm appending a node inside an element and would
I have an array that I'm appending to in a loop: array_push($obj->{$type.'listings'}, $listing); The
This is a question which isn't linked to any practical situation I'm in, but

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.