I was at How to change the href for a hyperlink using jQuery and there was an suggestion
With jQuery 1.6 and above you should use:
$("a").prop("href", "http://www.jakcms.com")
with the reason pointing to .prop() vs .attr(), whose updated answer was:
Update 1 November 2012
My original answer applies specifically to jQuery 1.6. My advice remains the same but jQuery 1.6.1 changed things slightly: in the face of the predicted pile of broken websites, the jQuery team [reverted
attr()to something close to (but not exactly the same as) its old behaviour for Boolean attributes][1]. John Resig also [blogged about it][2]. I can see the difficulty they were in but still disagree with his recommendation to preferattr().
Please pardon my ignorance but having read it over and over, I'm still at lost which one to choose, as up to now, every site/place I'm seeing are still using attr(). E.g.,
https://www.w3resource.com/jquery-exercises/jquery-core-exercise-9.php
was Last update on February 26 2020 this year.
I.e., if .prop() is the way to go, wouldn't everyone be using it 8/9 years later?
So which one should I use? What are the pros and cons of them both?
