Solved

createElement("button") makes a tiny little button

Posted on 2011-03-20
3
477 Views
Last Modified: 2012-05-11
Hi!

I am very new to javascript and there may well be a better way to do this than the way I am trying to do it, but the problem I have seems like it is something the should be trivial, despite my complete inability to fix it.

I am creating a number of form elements using javascript, including a submit button, using the following code.  

The problem is, the button appears and works, but it is super tiny and has no writing in it (at least none that I can see).

I have tried specifying height and width (first in the javascript and then in the div) - both seem to have failed to solve the problem.

If anyone can tell me how to make my submit button normally sized I would really appreciate it!
Thanks!


//this gets the div tag that I am appending the button to.
var sButton = document.getElementById("sbt");

//this creates my button
var submitting = document.createElement('button');
   submitting.setAttribute("name", "Submit");
   submitting.setAttribute("type", "submit");
   submitting.setAttribute("value","Submitted");

//this appends the button to the div
sButton.appendChild(submitting);

//this is the html code for the div
<div id = "sbt"></div>

Open in new window

0
Comment
Question by:JolineZ
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 250 total points
Comment Utility
Standard 'submit buttons' are <input> elements.  http://www.w3schools.com/tags/tag_input.asp  'buttons' are <input> elements.
0
 

Author Comment

by:JolineZ
Comment Utility
Thanks! I knew it had to be something silly and this fixed it immediately.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
thanks, glad to help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now