Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

createElement("button") makes a tiny little button

Posted on 2011-03-20
3
Medium Priority
?
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Accepted Solution

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

Author Comment

by:JolineZ
ID: 35177931
Thanks! I knew it had to be something silly and this fixed it immediately.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35177932
thanks, glad to help.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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)

636 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