zoukankan      html  css  js  c++  java
  • js封装

    方法一:

    function Tetrio(singleW){

            if(singleW == undefined){ singleW = 18; }

      this.x = 0;
      this.y = 0;
    }


    Tetrio.prototype.draw = function(context){
      
    }


    调用:
    var tetri = new Tetrio();
    tetri.draw(context);

     

    方法二:jason

    var AlertBox = {
        htmlTemplate:'<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
            <h4 class="modal-title" id="exampleModalLabel">$title$</h4>
          </div>
          <div class="modal-body">
              <div class="form-group">
                $content$
              </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" onclick="AlertBox.Close();">Close</button>
            <button type="button" class="btn btn-primary">Submit note</button>
          </div>
        </div>
      </div>
    </div>',
        Show: function (title, content) {
            var ht = this.htmlTemplate.replace('$title$', title);
            ht = ht.replace('$content$', content);
            $('body').append(ht);
            $('#myModal').modal('show');
        },
        Close: function () {
            $('.modal-backdrop').remove();
            $('#myModal').remove();
        }
    };

    调用:
    <a href="#" onclick="AlertBox.Show('Note','aaa');" ><i class="fa fa-comment"></i></a>

      

  • 相关阅读:
    ARP投毒攻击
    sniffer简单使用
    MAC泛洪攻击
    又是一题反序列化了解一下???
    关于parse_str变量覆盖分析
    超级ping(多线程版)
    文本输入框input将输入转换为统一大小写
    通俗易懂JSONP讲解
    通俗易懂JSONP讲解
    Fastjson主要接口和类库说明
  • 原文地址:https://www.cnblogs.com/aimyfly/p/4551844.html
Copyright © 2011-2022 走看看