Jquery动态生成html:
$.buildHTML = function (tag, htmltxt, attrs) {
// you can skip html param
if (typeof (htmltxt) != 'string') {
attrs = htmltxt;
htmltxt = null;
}
var h = '<' + tag;
for (attr in attrs) {
if (attrs[attr] === false) continue;
h += ' ' + attr + '="' + attrs[attr] + '"';
}
return $(h += htmltxt ? ">" + htmltxt + "</" + tag + ">" : "/>");
}
网友评论