标签:else logs query nbsp javascrip arrays isa style index
<script type="text/javascript">
function javascript() {
var isArraySel = $("#arrays-sel").prop("checked");
var htmlArr = $("#content").val().replace(/\\/g, "\\\\").replace(/\\/g, "\\/").replace(/\‘/g, "\\\‘").replace(/\"/g, "\\\"").split(‘\n‘);
var len = htmlArr.length;
var outArr = [];
if (isArraySel) {
outArr.push("[");
jQuery.each(htmlArr, function (index, value) {
if (value !== "") {
if (index === len - 1) {
outArr.push("\"" + value + "\"");
} else {
outArr.push("\"" + value + "\",\n");
}
}
});
outArr.push("].join(\"\");");
} else {
jQuery.each(htmlArr, function (index, value) {
if (value !== "") {
if (index === len - 1) {
outArr.push("\"" + value + "\";");
} else {
outArr.push("\"" + value + "\"+\n");
}
}
});
}
$("#result").val(outArr.join(""));
}
标签:else logs query nbsp javascrip arrays isa style index
原文地址:http://www.cnblogs.com/catgatp/p/6628620.html