day6作业

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>

    <div style="float: left;" id="div1">
        
        <div style="text-align: center;line-height: 30px; id="div2"  >
            
                
            <button  style=" width: 20px;height: 30px;" id="bt1" >X<p id="div3"  style=" width: 200px;height: 30px; background-color: rgb(144,144,144) ">香蕉</p></button>
            <br/>
            <button  style=" width: 20px;height: 30px;" id="bt1" >X<p id="div3"  style=" width: 200px;height: 30px; background-color: rgb(144,144,144) ">火龙果</p></button>
            <br/>
            <button  style=" width: 20px;height: 30px;" id="bt1" >X<p id="div3"  style=" width: 200px;height: 30px; background-color: rgb(144,144,144) ">西瓜</p></button>
        </div>  
            
        <br />
        <br />
        <input type="" name="i1" id="i1" value="" >
    </div>
    
</body>

</html>
<script type="text/javascript">
iNode = document.getElementById('i1')
iNode.onchange = function(){

        iNodes =  iNode.value
    
    
    p1Node = document.createElement('p')
    div1Node = document.getElementById('div1')  
    div1Node.insertBefore(p1Node, div1Node.firstElementChild)

// div1Node.appendChild(p1Node)
red = parseInt(Math.random()255)
green = parseInt(Math.random()
255)
blue = parseInt(Math.random()*255)

    p1Node.style = "background-color:rgb("+red+","+green+","+blue+");width: 200px;height: 30px;text-align: center;"
    p1Node.innerText = iNodes       
    
        
        
        
    
    
    
}
div1Node = document.getElementById('div1')
div2Node = document.getElementById('div2')
div3Node = document.getElementById('div3')

btn1Node = document.getElementById('bt1')   
div1Node.onclick = function(){
        dNode = btn1Node.parentElement

        div2Node.remove(dNode)
    
}

</script>

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容