git小乌龟箭头改星号_选中文字变成星号.html

选中文字变成星号

body {

font-size: 24px;

}

function testletter(letter) {

if (letter >= "a" && letter <= "z") {

return true;

}

if (letter >= "A" && letter <= "Z") {

return true;

}

return false;

}

function btnok() {

var range = window.getSelection().getRangeAt(0);

var container = document.createElement('div');

container.appendChild(range.cloneContents());

txt = container.innerHTML;

console.log("选中的文本" + txt);

arr = txt.split("");

txt2 = "";

for (i = 0; i < arr.length; i++) {

if (testletter(arr[i])) {

txt2 += "*";

} else {

txt2 += arr[i];

}

}

console.log("转换的文本" + txt2);

txt3 = document.getElementById("divinput").innerHTML;

txt4 = txt3.replace(txt, txt2);

document.getElementById("divinput").innerHTML = txt4;

}

function btncopy() {

txt = document.getElementById("area1").value;

document.getElementById("divinput").innerHTML = txt;

}

把要转换的文字复制进文本框,点击复制进网页,选中要转换的文字,点击转变星号

一键复制

编辑

Web IDE

原始数据

按行查看

历史


版权声明:本文为weixin_31597759原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。