Demo address: http://demo.jb51.net/js/2011/js_select/index.htm
Data
var data=[
{id:1,name:"Front-end Development",pid:0},
{id: 2,name:"CSS",pid:1},
{id:3,name:"JS",pid:1},
{id:4,name:"HTML",pid:1} ,
{id:5,name:"database",pid:0},
{id:6,name:"SQLServer",pid:5},
{id:7,name:" MYSql",pid:5},
{id:8,name:"Oracle",pid:5},
{id:9,name:"PLSQL",pid:8}
];
Infinite level select demo1
var demo1=Doc.Get("demo1");
var chg=function(obj){
if(obj.options.length>1){
obj.selectedIndex=0;
demo1.appendChild(obj);
}
}
var sel1=new Select(data,chg);
var _arr=sel1.getDom();
for(var i=0 ;i<_arr.length;i ){
demo1.appendChild(_arr[i]);
}
Infinite level select demo2
var demo2=Doc.Get("demo2");
var chg=function(obj) {
if(obj.options.length>1){
obj.selectedIndex=0;
demo2.appendChild(obj);
}
}
var sel=new Select (data,chg);
var _arr=sel.getDom(9);
for(var i=0;i<_arr.length;i ){
demo2.appendChild(_arr[i]) ;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn