Javascript 如何将平假名中的字符转换为片假名
我正在做一个项目,我有代码将英语音节转换成日语音节(平假名)。这是这样的:Javascript 如何将平假名中的字符转换为片假名,javascript,html,cjk,Javascript,Html,Cjk,我正在做一个项目,我有代码将英语音节转换成日语音节(平假名)。这是这样的: <html> <head> <script src="https://unpkg.com/wanakana"></script> </head> <body> <textarea id="typeshere" placeholder="Type here or click but
<html>
<head>
<script src="https://unpkg.com/wanakana"></script>
</head>
<body>
<textarea id="typeshere" placeholder="Type here or click buttons"></textarea>
<table>
<tr>
<td onclick="convert('ん')">
<div>ん</div>
<div>n</div>
</td>
<td onclick="convert('わ')">
<div>わ</div>
<div>wa</div>
</td>
</table>
<button>Convert</button>
<script>
/* typing input */
var input = document.getElementById('typeshere');
wanakana.bind(input);
/* button input */
function convert(x) {
input.value += x;
input.focus();
}
</script>
</body>
</html>
ん
N
わ
佤邦
转换
/*打字输入*/
var input=document.getElementById('typeshere');
bind(输入);
/*按钮输入*/
函数转换(x){
输入值+=x;
input.focus();
}
然而,我也需要能够切换到其他日语字母表(片假名),但我不知道如何做到这一点
以下是我正在尝试做的事情:
- 单击按钮,将表中的所有平假名转换为片假名(包括函数)
- 当用户现在使用此表或在框中键入时,将使用片假名
- 但是,我还需要将已经添加到的字符保留为平假名
- 最后,我需要能够反复使用按钮,在需要时在两个字母之间切换