Obiekt przycisku wejściowego HTML DOM
Obiekt przycisku wejściowego
Obiekt Input Button reprezentuje element HTML <input> z type="button".
Uzyskaj dostęp do obiektu przycisku wejściowego
Możesz uzyskać dostęp do elementu <input> z type="button" za pomocą getElementById():
Przykład
var x = document.getElementById("myBtn");
Wskazówka: możesz również uzyskać dostęp do <input type="button"> przeszukując kolekcję elementów formularza.
Utwórz obiekt przycisku wejściowego
Możesz utworzyć element <input> z type="button" za pomocą metody document.createElement():
Przykład
var x = document.createElement("INPUT");
x.setAttribute("type", "button");
Właściwości obiektu przycisku wejściowego
Property | Description |
---|---|
autofocus | Sets or returns whether an input button should automatically get focus when the page loads |
defaultValue | Sets or returns the default value of an input button |
disabled | Sets or returns whether an input button is disabled, or not |
form | Returns a reference to the form that contains the input button |
name | Sets or returns the value of the name attribute of an input button |
type | Returns which type of form element the input button is |
value | Sets or returns the value of the value attribute of an input button |
Standardowe właściwości i zdarzenia
Obiekt Input Button obsługuje również standardowe właściwości i zdarzenia .
Powiązane strony
Samouczek HTML: formularze HTML
Odniesienie HTML: tag HTML <input>
Odniesienie HTML: atrybut typu HTML <input>