WebRoot/frame/js/jquery.appendDom.js
(完整代码) 1KB/**
*
* appendDom - Extremely flexible tool for dynamic dom creation.
* http://byron-adams.com/projects/jquery/appendDom
*
* Copyright (c) 2007 Byron Adams (byron.adams54@gmail.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* 11/03/09 - Bugs fixed by Patricio Palladino pato89 (at) gmail (dot)com
*
*/
jQuery.fn.appendDom = function(template) {
return this.each(function() {
for (element in template) {
var el = (typeof(template[element].tagName) === 'string') ?
document.createElement(template[element].tagName) :
document.createTextNode('');
delete template[element].tagName;
for (attrib in template[element]){
if(attrib == 'className'){
jQuery(el).addClass(template[element][attrib]);
delete template[element].className;
}
switch ( typeof(template[element][attrib]) ) {
case 'string' :
if ( typeof(el[attrib]) === 'string' ) {
el[attrib] = template[element][attrib];
} else {
el.setAttribute(attrib, template[element][attrib]);
}
break;
case 'function':
el[attrib] = template[element][attrib];
break;
case 'object' :
if (attrib === 'childNodes') jQuery(el).appendDom(template[element][attrib]);
break;
}
}
this.appendChild(el);
}
});
};
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
