Dowemo


<!DOCTYPE html>


<html lang="en">


<head>


 <meta charset="UTF-8">


 <title>Document</title>


</head>


<body>


<a id="create" href="javascript:void(0)">创建列表</a>



</body>


</html>



<script type="text/javascript">


 var create = document.getElementById("create");


 var ul = document.createElement("ol");


 var num = 0;


 create.addEventListener("click",function () {


 tree(ul,{"width":100})


 },false);



function tree(obj,paramas) {


 if ( paramas == undefined) {


 return;


 }else {


 var li = document.createElement("li");


 if (paramas.background!== undefined) {


 li.style.background = paramas.background.toString();


 }else {


 li.style.background = "blue";


 }


 if (paramas.width!== undefined) {


 li.style.width = parseFloat(paramas.width)+'px';


 }else {


 li.style.width = 50+'px';


 }


 obj.append(li);


 document.body.append(obj);


 }


}



</script>









Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs