merlin

精益求精

孤鸿

导航

[js]dom

//判断浏览器

var cb = "Unknown";
if(navigator.userAgent.toLowerCase().indexOf("chrome") != -1){
        cb = "Chrome";
        alert(cb);
    }

document.getElementById('id').className//获取class 

//div元素
document.getElementById('id').tagName.toLowerCase()  //div
document.getElementsByTagName('div').tagName.toLowerCase()  //div
document.getElementsByTagName('div').tagName.toUpperCase()  //DIV

//获取设置移除属性 attribute
 var div=document.getElementById('parent');
 alert(div.getAttribute('id'));//id值
 alert(div.setAttribute('id','hello'));//将div的id值设置成hello
 alert(div.removeAttribute('class'));//将calss属性移除

 //创建元素
 function LoadJs(url){
		var script =document.createElement("script");
		script.type="text/javascript";
		script.src=url;
		document.body.appendChild(script);
	}

  

posted on 2013-05-31 17:48  天地一连线_孤鸿挂飘渺  阅读(219)  评论(0编辑  收藏  举报