2018年5月12日 星期六

[JavaScript] common

更新craeteElement,自動將建立的元件加入到parent。
===
var common = {};
common.createElement = function (tag, attributes, parent) {
    var element = document.createElement(tag);
    for (var attribute of attributes) {
        element.setAttribute(attribute, attributes[attribute]);
    }
    if (parent !== undefined) {
        parent.appendChild(element);
    }
    return element;
};
===.

[HTML] ribody

怕自己忘記,稍微紀錄一下。 各種各種理由(其中一個就是Vue,不能綁定在body上),導致時常需要一個包在body中的div,當作body來用,像這樣: === <body>     <div id="divBody">   ...