zoukankan      html  css  js  c++  java
  • javascript操作css实现弹出对话框

    尝试运行代码效果:

     ------------------------------------------效果-----------------------------------------------

     

     -----------------------------------------代码-----------------------------------------------------------------------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function ss(){
    var div=document.createElement("div");
    var textarea=document.createElement("textarea");

    var button=document.createElement("input");
    button.type='button';
    button.value='OK';
    button.onclick=function(){
    document.getElementById("show").value=textarea.value;
    document.body.removeChild(button);
    document.body.removeChild(textarea);
    document.body.removeChild(div);
    }
    setStyle(div,{
    'position':'absolute',
    'left':0,
    'top':0,
    'bottom':0,
    'right':0,
    'backgroundColor':'black',
    'opacity':.5,
    'filter':'alpha(opacity=50)'
    });
    setStyle(button,{
    'position':'absolute',
    'left':'250px',
    'top':'160px'
    })
    setStyle(textarea,{
    'position':'absolute',
    'left':'100px',
    'top':'100px'
    })
    document.body.appendChild(div);
    document.body.appendChild(button);
    document.body.appendChild(textarea);


    }
    function setStyle(dom,style){
    for(var i in style){
    if(style.hasOwnProperty(i)){
    dom.style[i]=style[i];
    }
    }
    }
    </script>
    </head>

    <body>
    <input type="text" id="show" />
    <input type="button" value="输入" onclick="ss()">
    </body>
    </html>

  • 相关阅读:
    (转)消息队列 Kafka 的基本知识及 .NET Core 客户端
    Neo4j学习笔记
    科技论文推荐系统
    下载pubmed数据
    杂项
    Scrapy 知乎验证码
    Scrapy 爬取网站文章
    爬虫基础知识
    Django linux uWsgi Nginx 部署
    DocumentSimilarity
  • 原文地址:https://www.cnblogs.com/jiangwenli/p/4870391.html
Copyright © 2011-2022 走看看