首页 > > > jquery学习手记(3)属性
属性的格式如下:
$.fn.attr该格式既可以获取属性的值也可以设置属性的值。示例如下:
设置属性
1 // Setting attributes
2 $("a").attr( "href", "allMyHrefsAreTheSameNow.html" );
3 $("a").attr({
4 title: "all titles are the same too!",
5 href: "somethingNew.html"
6 });获取属性
1 // Getting attributes
2 $("a").attr("href"); // returns the href for the first a element in the document
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69901620/viewspace-3158490/ ,如需转载,请注明出处,否则将追究法律责任。