كائن زر الإدخال HTML DOM
كائن زر الإدخال
يمثل كائن زر الإدخال عنصر <input> HTML مع type = "button".
الوصول إلى كائن زر الإدخال
يمكنك الوصول إلى عنصر <input> من خلال النوع = "button" باستخدام getElementById ():
مثال
var x = document.getElementById("myBtn");
نصيحة: يمكنك أيضًا الوصول إلى <input type = "button"> بالبحث خلال مجموعة عناصر النموذج.
قم بإنشاء كائن زر الإدخال
يمكنك إنشاء عنصر <input> بالنوع = "button" باستخدام طريقة document.createElement ():
مثال
var x = document.createElement("INPUT");
x.setAttribute("type", "button");
خصائص كائن زر الإدخال
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 |
الخصائص القياسية والأحداث
كما يدعم كائن زر الإدخال الخصائص والأحداث القياسية .
الصفحات ذات الصلة
دروس HTML: نماذج HTML
مرجع HTML: علامة <input> HTML
مرجع HTML: سمة نوع <إدخال> HTML