添加屬性
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);//獲取絕對路徑
