中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

JavaScript動態(tài)創(chuàng)建div等元素實(shí)例

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
    <html>  
        <head>  
        <title>js動態(tài)創(chuàng)建div等元素實(shí)例</title>  
        <style type="text/css">  
        </style>  
        </head>  
        <body>  
        <script language="javascript">  
            var Test={  
                createDiv:function(){  
                    var div = document.createElement('div');  
                    div.id="createDiv";  
                    div.style.cssText = 'border:1px solid red; width:200px; z-index:100; height:20px;';  
                    document.body.appendChild(div);  
                },  
                appendDivChild:function(){  
                    var div = document.createElement('div');  
                    div.id="appendDivChild";  
                    div.style.cssText = 'border:1px solid green; width:400px; z-index:100; height:100px;';  
                    var childDiv= document.createElement('div');  
                    childDiv.id="childDiv";  
                    childDiv.style.cssText = 'border:2px solid gray; width:200px; z-index:100; height:50px;';  
                    div.appendChild(childDiv);  
                    document.body.appendChild(div);  
                },  
                createSelect:function(){  
                    var select=document.createElement('select');  
                    select.id="select";  
                    var option1=document.createElement('option');  
                    option1.value=1;  
                    option1.text=1;//非ie,添加內(nèi)容  
                    option1.innerHTML=1;//ie,添加內(nèi)容  
                    select.appendChild(option1);  
                    var option2=document.createElement('option');  
                    option2.value=2;  
                    option2.text=2;  
                    option2.innerHTML=2;  
                    select.appendChild(option2);  
                    var option3=document.createElement('option');  
                    option3.value=3;  
                    option3.text=1;  
                    option3.innerHTML=3;  
                    select.appendChild(option3);  
                    document.body.appendChild(select);  
                },  
                createRadio:function(){  
                    var radio=document.createElement('input');  
                    radio.id='radio';  
                    radio.type="radio";  
                    radio.width="100";  
                    var label=document.createElement('label');  
                    label.text="男";  
                    label.innerHTML="男";  
                    document.body.appendChild(radio);  
                    document.body.appendChild(label);  
                }  
            };  
            Test.createDiv();//創(chuàng)建div  
            Test.appendDivChild();//為追加子div  
            Test.createSelect();//創(chuàng)建下拉框  
            Test.createRadio();//創(chuàng)建單選按鈕  
        </script>  
        <select>  
            <option>1</option>  
            <option>2</option>  
            <option>3</option>  
        </select>  
        </body>  
    </html>  

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:java properties增刪改查

下一篇:java zip壓縮與解壓-支持空目錄,保留文件修改時(shí)間