Compared with inputtypebutton, the button control provides more powerful functions and richer content. All content between the button and the button tag is the content of the button, including any acceptable body content, such as text or multimedia content. For more information, see
Tag
Definition and usage
Tag defines a button.
Inside the button element, you can place content, such as text or images. This is the difference between this element and the button created using the input element.
Controls and It provides more powerful functions and richer content. AndAll content between tags is button content, including any acceptable body content, such as text or multimedia content. For example, you can include an image and related text in a button and use them to create an attractive labeled image in the button.
The only prohibited element is image ing because its mouse-and keyboard-sensitive actions interfere with form buttons.
Always define the type attribute for the button. The default InternetExplorer type is "button", while the default value for other browsers (including W3C specifications) is "submit ".
Browser support
All mainstream browsers support Label.
Important: If the button element is used in an HTML form, different browsers submit different values. InternetExplorer will submit And And other browsers will submit the content of the value attribute. Use the input element in the HTML form to create a button.
Notes
In use Tags are easy to take for granted. This can easily produce the following errors:
1. Get it through $ ('# mbmbtn'). val () Button Value
In IE (IE kernel), the value is "button" instead of "test". Instead of "test" in IE, the value is "test ". In the first sentence marked with red above.
This must be consistent Separated.
Use these two methods $ ('# mbmbtn'). val (), $ ('# customBtn'). attr ('value') to obtain values in different browsers:
Browser/Value |
$ ('# CustomBtn'). val () |
$ ('# CustomBtn'). attr ('value ') |
Firefoxbench |
Test |
Test |
Chrome15.0 |
Test |
Test |
Opera11.61 |
Test |
Test |
Safari5.1.4 |
Test |
Test |
IE9.0 |
Button |
Button |
Verify this by testing the following code:
The Code is as follows:
Script
$ (Function (){
$ ('# Test1'). click (function (){
Alert ($ ('# mbmbtn'). attr ('value '));
});
$ ('# Test2'). click (function (){
Alert ($ ('# mbmbtn'). val ());
});
});
Script
Button
2. Accidentally Tag