كائن مربع اختيار إدخال HTML DOM
إدخال كائن مربع الاختيار
يمثل كائن Input Checkbox عنصر HTML <input> مع type = "checkbox".
الوصول إلى كائن خانة اختيار الإدخال
يمكنك الوصول إلى عنصر <input> بالنوع = "checkbox" باستخدام getElementById ():
مثال
var x = document.getElementById("myCheck");
نصيحة: يمكنك أيضًا الوصول إلى <input type = "checkbox"> من خلال البحث في مجموعة عناصر النموذج.
قم بإنشاء كائن خانة اختيار الإدخال
يمكنك إنشاء عنصر <input> بالنوع = "checkbox" باستخدام طريقة document.createElement ():
مثال
var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");
خصائص كائن خانة اختيار الإدخال
Property | Description |
---|---|
autofocus | Sets or returns whether a checkbox should automatically get focus when the page loads |
checked | Sets or returns the checked state of a checkbox |
defaultChecked | Returns the default value of the checked attribute |
defaultValue | Sets or returns the default value of a checkbox |
disabled | Sets or returns whether a checkbox is disabled, or not |
form | Returns a reference to the form that contains the checkbox |
indeterminate | Sets or returns the indeterminate state of the checkbox |
name | Sets or returns the value of the name attribute of a checkbox |
required | Sets or returns whether the checkbox must be checked before submitting a form |
type | Returns which type of form element the checkbox is |
value | Sets or returns the value of the value attribute of a checkbox |
الخصائص القياسية والأحداث
يدعم كائن Input Checkbox أيضًا الخصائص والأحداث القياسية .
الصفحات ذات الصلة
دروس HTML: نماذج HTML
مرجع HTML: علامة <input> HTML
مرجع HTML: سمة نوع <إدخال> HTML