开发者社区> 问答> 正文

请前段JS大神帮忙改一下js部分的代码!改的越简单越好,我感觉我写的很复杂

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" /> 
        <title>layui</title> 
        <meta name="keywords" content="关键词,5个左右,单个8汉字以内"> 
        <meta name="description" content="网站描述,字数尽量空制在80个汉字,160个字符以内!"> 
        <link rel="Bookmark" href="favicon.ico" > 
        <link rel="Shortcut Icon" href="favicon.ico" /> 
        <link href="../css/cui.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
            #popup-page{display:none}
        </style>
    </head> 
    <body>
        <div id="popup" >弹出</div>
        <div id="popup-page" >1213123</div>
        <script type="text/javascript" src="http://www.tiexinbaoxian.com/templets/default/js/jquery-1.9.1.min.js"></script>  
        <script type="text/javascript" src="http://www.tiexinbaoxian.com/templets/default/js/layer/layer.js"></script>
        <script type="text/javascript">
 
                /*调用选择绑定点击事件种类*/
                window.onload = function() {
                    var popupID = document.getElementById("popup");  
                    EventUtil.addEventHandler(popupID, "click", PopupFunction);
                }
                /*弹出层*/
                function handleOnblur(div) {
                    layer.open({
                        type: 1,
                        title:'选择举报原因',
                        skin: 'layui-layer-rim', //加上边框
                        area: ['350px', '250px'], //宽高
                        content: $('#popup-page'),
                        btn: ['确认', '取消'],
                        yes: function(){ //或者使用btn1
                            layer.closeAll();
                        }
                    })
                }  
                /*调用弹出层方法*/
                var PopupFunction = function(popupid){
                    handleOnblur(popupid);
                } 
                /*选择绑定点击事件种类*/
                var EventUtil = new Object;
                EventUtil.addEventHandler = function (oTarget, sEventType, fnHandler) {
                    if (oTarget.addEventListener) {
                        oTarget.addEventListener(sEventType, fnHandler, false);
                    } else if (oTarget.attachEvent) {
                        oTarget.attachEvent("on" + sEventType, fnHandler);
                    } else {
                        oTarget["on" + sEventType] = fnHandler;
                    }
                };
  
 
        </script>
    </body>
</html>

展开
收起
a123456678 2016-07-18 10:24:51 1798 0
1 条回答
写回答
取消 提交回答
  • $(function(){
        var handleOnblur = function (div) {
            layer.open({
                type: 1,
                title:'选择举报原因',
                skin: 'layui-layer-rim', //加上边框
                area: ['350px', '250px'], //宽高
                content: $('#popup-page'),
                btn: ['确认', '取消'],
                yes: function(){ //或者使用btn1
                    layer.closeAll();
                }
            });
        };
     
        $('#popup').on('click', function(){
            handleOnblur(this);
        });
    });
    2019-07-17 19:57:33
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
JavaScript面向对象的程序设计 立即下载
Delivering Javascript to World 立即下载
编程语言如何演化-以JS的private为例 立即下载