Text 如何:页面上有2个文本字段,点击按钮时替换字符
我自己不是一个开发人员,尽管html和css对我来说有点熟悉,但php和更高级的语言并不是这样,请耐心听我html文件Text 如何:页面上有2个文本字段,点击按钮时替换字符,text,replace,paste,Text,Replace,Paste,我自己不是一个开发人员,尽管html和css对我来说有点熟悉,但php和更高级的语言并不是这样,请耐心听我html文件 我希望有帮助^_& 嗨,弗洛林。谢谢你的回复,我已经修改了答案。让我知道,如果这是你要找的。是的!!!在这种情况下,它也会起作用。没问题,很乐意帮忙,幸好没用。。。看看这个我有代码的网站:使用我那里的文本示例,你会看到A没有被转换成O <input id="input_data" type="text"> <button id="convert">Co
我希望有帮助^_& 嗨,弗洛林。谢谢你的回复,我已经修改了答案。让我知道,如果这是你要找的。是的!!!在这种情况下,它也会起作用。没问题,很乐意帮忙,幸好没用。。。看看这个我有代码的网站:使用我那里的文本示例,你会看到A没有被转换成O
<input id="input_data" type="text">
<button id="convert">Convert</button>
<div>
<h1>Output</h1>
<p id="output"></p>
</div>
<script type="text/javascript">
document.getElementById("convert").onclick = function(){
var input = document.getElementById("input_data").value;
// your choice
var convert_from = "a";
var convert_to = "o";
var finalString = (input.split(convert_from.toUpperCase()).join(convert_to.toUpperCase())).split(convert_from).join(convert_to);
document.getElementById("output").textContent = finalString;
copyToClipboard(finalString);
}
// You can copy some text to clipboard only by selecting an element
function copyToClipboard(content){
// Create a textarea
var textHolder = document.createElement('textarea');
// Assign the value
textHolder.value = content;
// Appent the textarea to body
document.body.appendChild(textHolder);
// "Focus the action" on the textHolder
textHolder.select();
textHolder.setSelectionRange(0, 99999); /*For mobile devices*/
// Copy the content from selected element
document.execCommand('copy');
// Remove the textarea from body
document.body.removeChild(textHolder);
}
</script>