The JQuery attr () method is used to set/change the property value, and the following example shows how to change the value of the href attribute in the link (set)
Set Properties-The attr () JQuery attr () method is also used to set/change property values. The following example shows how to change the value of the href attribute in a link: the instance code is as follows: $ ("button"). Click (function () {$ (#keleyi). attr ("href", "http://www.jb51.net") ; }); The attr () method also allows you to set multiple properties at the same time. The following example shows how to set the href and title properties at the same time: instance copy code code as follows: $ ("button"). Click (function () {$ (#keleyi). attr ({"href": "Http://ww W.jb51.net "," title ":" Collayi Net "}); }); The attr () callback function, the JQuery method attr (), also provides a callback function. The callback function consists of two parameters: the subscript for the current element in the selected element list, and the original (old) value. Then return the string you want to use with the new value of the function. The following example shows the attr () method with a callback function: the instance code is as follows: $ ("button"). Click (function () {$ ("#keleyi"). attr ("href", function (i,origvalue) {RET Urn Origvalue + "/jquery"; }); });