PDA

View Full Version : <button type="button">Click Me!</button>



Darqniz
02-23-2011, 08:02 AM
Are there other button types besides this default one? If there is only one type of button then why add the <button type="button"> why not just <button>?

bullant
02-23-2011, 08:37 AM
The <button> element doesn't need a "type=" attribute.

The <input> element needs a type attribute if it is to be a button <input type="button" name="myButton" value="Click me.!" />

abduraooft
02-23-2011, 09:49 AM
Are there other button types besides this default one? If there is only one type of button then why add the <button type="button"> why not just <button>?


The <button> element doesn't need a "type=" attribute.

The <input> element needs a type attribute if it is to be a button <input type="button" name="myButton" value="Click me.!" />

Yes, it has!
Read http://htmldog.com/reference/htmltags/button/

bullant
02-23-2011, 10:18 AM
Yes, it has!


"Yes, it has", what?

The type attribute is optional for the <button> element.

abduraooft
02-23-2011, 10:20 AM
"Yes, it has", what?

The type attribute is optional for the <button> element.
May be, but OP asked
Are there other button types besides this default one?

bullant
02-23-2011, 10:34 AM
and I replied with



The <input> element needs a type attribute if it is to be a button <input type="button" name="myButton" value="Click me.!" />

I'm not sure what the "it" is that you say "has" something. But never mind, it's not important.

abduraooft
02-23-2011, 10:57 AM
and I replied with



I'm not sure what the "it" is that you say "has" something. But never mind, it's not important.
But the OP didn't ask about <input>. Why are you mixing the original question with the characteristic of an <input> element?

bullant
02-23-2011, 11:00 AM
I don't think I'm mixing up anything.

The op asked



Are there other button types besides this default one?


and the answer is yes - an input button.

VIPStephan
02-23-2011, 12:17 PM
Bullant, I think you’re a little picky here. The OP meant to ask if there are other values for the type attribute of the button element. And there are, for example <button type="submit"></button>.

bullant
02-23-2011, 01:51 PM
The OP meant to ask if there are other values for the type attribute of the button element. And there are, for example <button type="submit"></button>.

I don't know what the op really meant to ask because their question as worded is ambiguous, so I answered according to what I thought the op asked.

Darqniz
02-24-2011, 12:35 AM
Bullant, I think you’re a little picky here. The OP meant to ask if there are other values for the type attribute of the button element. And there are, for example <button type="submit"></button>.

Yep and sorry for the confusion.

bullant
02-24-2011, 12:39 AM
Yep and sorry for the confusion.

no problem, no harm done :)

Arbitrator
02-24-2011, 12:04 PM
Are there other button types besides this default one? If there is only one type of button then why add the <button type="button"> why not just <button>?The type attribute specifies the element's behavior when it appears inside a form element. As already mentioned, there are three values that specify different behaviors.

When the button element appears inside a form element, type="button" has no default behavior and essentially does nothing unless scripted events are tied to it; type="submit" submits the form (by default, form information is submitted to the location specified in the form element's action attribute); and type="reset" resets the form to its default state. (type="reset" is generally misunderstood and rarely used properly; it's supposed to be used for forms that are submitted multiple times with different data (like you would do when entering records into a database).)

Outside of a form element, all three type values (i.e., button, submit, and reset) behave like button. (That should make sense since there's nothing to submit or reset.)