If I want to change the href of a link dynamically, should I do so using prop()
or attr()
?
You would use .attr()
, as .prop()
is more commonly used for boolean properties such as checked
, selected
, etc - though it is certainly possible with .prop
it's arguably less clear as per your intent
Though I do believe that ultimately they are very similar (or used to be) functionality-wise
Just a note: the jQuery API site seems to follow the boolean 'sway':
.prop()
- Examples use checked
and disabled
.attr()
- Examples use alt
title
and src