odiv.setAttribute("title","hello div!");
odiv.setAttribute("class","boxClass");
odiv.setAttribute("hello","divTag");//自定義屬性設(hello="divTag")
var v=odiv.getAttribute("hello");
console.log(v);//divTag
console.log(odiv["hello"]);//undefiend
odiv.removeAttribute("title");//參數:屬性名
//路徑相關屬性
var oImg = document.getElementsByTagName("img")[0];
var url=oImg.getAttribute("src")
console.log(url);//圖檔相對路徑
var url2 = oImg.src;
console.log(url2);//擷取絕對路徑
更多專業前端知識,請上 【猿2048】www.mk2048.com