?
? ????? PHP ??? ???? ??? ?? ??
設(shè)置或返回被選元素的屬性值。
屬性名稱(chēng)
作為屬性的“名/值對(duì)”對(duì)象
屬性名稱(chēng),屬性值
1:屬性名稱(chēng)。
2:返回屬性值的函數(shù),第一個(gè)參數(shù)為當(dāng)前元素的索引值,第二個(gè)參數(shù)為原先的屬性值。
返回文檔中所有圖像的src屬性值。
$("img").attr("src");
為所有圖像設(shè)置src和alt屬性。
$("img").attr({ src: "test.jpg", alt: "Test Image" });
為所有圖像設(shè)置src屬性。
$("img").attr("src","test.jpg");
把src屬性的值設(shè)置為title屬性的值。
$("img").attr("title", function() { return this.src });