- For HTML elements that have intrinsic properties, use the Prop method when processing.
- For HTML elements our own custom DOM properties, when processing, use the Attr method.
HTML file
<tr> <th></th> <td> class= "Easyui-linkbutton" style= "width:60px;" Onclick= "SelectAll ()" > select all </a> class= "Easyui-linkbutton" style= "width:60px;" onclick= " Unselectall () "> select all </a> </td> </tr>
JS file
Assign a property value to a checkbox of the same name
function SelectAll () { $ (' input[name= "Groupitem"] '). Val (function (index,val) { $(This ). Prop (' checked ',true);
$ (this). attr (' checked ', true);// error return val; })} function Unselectall () { $ (' input[name= ' Groupitem "] '). Val (function (index,val) { $ ( this). Prop (' checked ',false);
//$ (this). attr (' checked ', false); error return val; })}
Examples of the differences between attr and prop of jquery