Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将平假名中的字符转换为片假名_Javascript_Html_Cjk - Fatal编程技术网

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();
}
然而,我也需要能够切换到其他日语字母表(片假名),但我不知道如何做到这一点

以下是我正在尝试做的事情:

  • 单击按钮,将表中的所有平假名转换为片假名(包括函数)
  • 当用户现在使用此表或在框中键入时,将使用片假名
  • 但是,我还需要将已经添加到的字符保留为平假名
  • 最后,我需要能够反复使用按钮,在需要时在两个字母之间切换
我已经用尽了我的JS知识,我很想知道下一步我需要做什么才能让它工作

谢谢