Introduction to the use of jquery prop and the difference with attr

  • 2020-03-30 01:00:34
  • OfStack

Prop and attr work similarly

Similarities: both can get and set property values
Difference: when dealing with a checkbox, prop is recommended because the Internet explorer browser is not compatible, as it is recommended by all individuals alike
RemoveProp (" XXX ") removeProp(" XXX ")
Get attribute value
var currentChecked=$(".my-checked").prop("checked");  A value of true/false 

Setting property values
var currentChecked=$(".my-checked").prop("checked" . false); 

Related articles: