Skip to main content
Copy edited (e.g. ref. <http://english.stackexchange.com/questions/4645/is-it-ever-correct-to-have-a-space-before-a-question-or-exclamation-mark#comment206109_4645>).
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 109
  • 132

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked"); //will Will give you undefined as initial value of checkbox is not set

If prop is used  :

$(element).prop("checked"); //will Will give you false whether or not initial value is set 

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// mayMay be like this also  checked="true"

attr used:

$(element).attr("checked") //will Will return checked whether it is checked="true"

propProp used:

$(element).prop("checked") //will Will return true whether checked="checked" 

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked");//will give you undefined as initial value of checkbox is not set

If prop is used  :

$(element).prop("checked");//will give you false whether or not initial value is set 

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// may be like this also  checked="true"

attr used:

$(element).attr("checked")//will return checked whether it is checked="true"

prop used:

$(element).prop("checked")//will return true whether checked="checked" 

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked"); // Will give you undefined as initial value of checkbox is not set

If prop is used:

$(element).prop("checked"); // Will give you false whether or not initial value is set

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// May be like this also  checked="true"

attr used:

$(element).attr("checked") // Will return checked whether it is checked="true"

Prop used:

$(element).prop("checked") // Will return true whether checked="checked"
"prop used" following code sample was using attr
Source Link
Alex Sorokoletov
  • 3.1k
  • 2
  • 30
  • 52

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked");//will give you undefined as initial value of checkbox is not set

If prop is used :

$(element).prop("checked");//will give you false whether or not initial value is set 

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// may be like this also  checked="true"

attr used:

$(element).attr("checked")//will return checked whether it is checked="true"

prop used:

$(element).attrprop("checked")//will return true whether checked="checked" 

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked");//will give you undefined as initial value of checkbox is not set

If prop is used :

$(element).prop("checked");//will give you false whether or not initial value is set 

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// may be like this also  checked="true"

attr used:

$(element).attr("checked")//will return checked whether it is checked="true"

prop used:

$(element).attr("checked")//will return true whether checked="checked" 

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked");//will give you undefined as initial value of checkbox is not set

If prop is used :

$(element).prop("checked");//will give you false whether or not initial value is set 

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// may be like this also  checked="true"

attr used:

$(element).attr("checked")//will return checked whether it is checked="true"

prop used:

$(element).prop("checked")//will return true whether checked="checked" 
Source Link
Somnath Kharat
  • 3.6k
  • 2
  • 30
  • 51

1) If your HTML markup is:

<input type="checkbox"  />

attr used:

$(element).attr("checked");//will give you undefined as initial value of checkbox is not set

If prop is used :

$(element).prop("checked");//will give you false whether or not initial value is set 

2) If your HTML markup is:

 <input type="checkbox"  checked="checked" />// may be like this also  checked="true"

attr used:

$(element).attr("checked")//will return checked whether it is checked="true"

prop used:

$(element).attr("checked")//will return true whether checked="checked" 
Post Made Community Wiki by Somnath Kharat