ITPub博客

首页 > > > jquery学习手记(3)属性

jquery学习手记(3)属性

作者:zhmw 时间:2020-01-07 18:06:00 0 删除 编辑

属性的格式如下:

$.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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-12-04

  • 博文量
    295
  • 访问量
    9532