1. 獲取屬性的值attr(name)
- $("img").attr("src");
2. 修改屬性attr(name,value)
- $("img").attr("src","test.jpg");
3. 一次修改多個屬性attr(properties)
- $("img").attr({ src: "test.jpg", alt: "Test Image" });
4. 用function變更屬性的值 attr(key, function(index, attr))
- $("img").attr("title", function() { return this.src });
5. 移除屬性removeAttr(name)
- $("img").removeAttr("src");
0 意見:
張貼留言