Input Checkbox checked Attribute

Definition and Usage

checked Sets or returns the checked state of the checkbox.

This attribute reflects the HTML checked attribute.

See also:

HTML Reference Manual:HTML <input> checked এট্রিবিউট

Example

Example 1

Set the checked state of the checkbox:

function check() {
    document.getElementById("myCheck").checked = true;
}
function uncheck() {
    document.getElementById("myCheck").checked = false;
}

Try it yourself

Example 2

Check if the checkbox is selected:

var x = document.getElementById("myCheck").checked;

Try it yourself

Example 3

Use checkboxes to convert text in input fields to uppercase:

document.getElementById("fname").value = document.getElementById("fname").value.toUpperCase();

Try it yourself

Example 4

Several checkboxes in the form:

var coffee = document.forms[0];
var txt = "";
var i;
for (i = 0; i < coffee.length; i++) {
  if (coffee[i].checked) {
    txt = txt + coffee[i].value + " ";
  }
}
document.getElementById("order").value = "You ordered coffee with: " + txt;

Try it yourself

Syntax

Return checked attribute:

checkboxObject.checked

set checked attribute:

checkboxObject.checked = true|false

এট্রিবিউট মান

মান বর্ণনা
true|false

চেকবক্সটি নির্বাচিত হওয়াকে নির্দিষ্ট করে

  • true - চেকবক্স নির্বাচিত
  • false - ডিফল্ট।চেকবক্স নির্বাচিত নয়

প্রযুক্তিগত বিবরণ

ফলাফল বুল মান, যদি চেকবক্স নির্বাচিত হয়, তবে trueযদি চেকবক্স নির্বাচিত না হয়, তবে false

ব্রাউজার সমর্থন

চ্রোম এজ ফায়ারফক্স স্যাফারি অপেরা
চ্রোম এজ ফায়ারফক্স স্যাফারি অপেরা
সমর্থন সমর্থন সমর্থন সমর্থন সমর্থন