zoukankan      html  css  js  c++  java
  • js动态生成div和事件

    <script language=javascript>
            var divId=1;
            //动态生成单纯的div
            function CreateOuterDiv()
            {
                var obj=document.createElement("div");
                obj.id="myDiv"+divId;
                divId++;
                obj.style.border="1px solid #000000";
                obj.style.height="30px";
                obj.style.width="200px";
                obj.style.filter="alpha(opacity=70)";           
                obj.style.margin="10px";    
                obj.style.cursor="hand";
                obj.algin="center";      
                //obj.innerHTML="<a href='#"+obj.id+"'>ssssssssss</a>";
                obj.innerText="sssssss";
               
                document.body.appendChild(obj);         
                document.getElementById(obj.id).onclick=function(){aa();};           
            }
            function aa()
            {
                CreateOuterDiv();//alert();
            }      
        </script>
  • 相关阅读:
    RichEdit
    用 RAD Studio 柏林版创建 IoT 应用程序
    延时程序
    SQL if exists用法
    Firemonkey限制TEdit只能输入数字的完美方法
    leetcode 树
    leetcode string
    clone-graph
    surrounded-regions merge-intervals
    leetcode链表题
  • 原文地址:https://www.cnblogs.com/see7di/p/2239847.html
Copyright © 2011-2022 走看看