difference between jQuery .val() and .attr('value')?

.val() works on all input type elements in a useful way, including ...even in the cases of , checkboxes, and radio buttons (in which .val() ...


.val() works
on all input type elements in a useful way, including
,
checkboxes, and radio buttons (in which .val() gets or sets an array of selected values not just a string).


So basically they serve different purposes, even though .attr('value') behaves the same in some situations, like textboxes. The preferred method is .val() to get

Hot in Week

Popular

Archive

item