Home > Article > Web Front-end > JS implements methods to obtain various pinyin types
This article mainly introduces the method of JS to obtain the pinyin, full pinyin and mixed pinyin of the first letter of Chinese characters. It involves the use of ChinesePY.js plug-in and event response related operation skills. Friends who need it can refer to it. I hope it can help everyone. .
The running effect is as follows:
Complete sample code:
<!DOCTYPE HTML> <html> <head> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript" src="ChinesePY.js"></script> </head> <body style="font-size:12px"> <form> 输入内容: <input type="text" onkeyup="pym.innerHTML = Pinyin.GetJP(this.value);allpym.innerHTML=Pinyin.GetQP(this.value); staffpym.innerHTML=Pinyin.GetHP(this.value);" /> <br /><br /> 拼 音 码: <span id="pym"></span><br /><br /> 拼音全码: <span id="allpym"></span><br /><br /> 混 拼 码: <span id="staffpym"></span> </form> </body> </html>
Have you learned it? If it is useful, collect it quickly.
Related recommendations:
How to obtain Chinese pinyin in Java Introduction to the method of initial letters
The above is the detailed content of JS implements methods to obtain various pinyin types. For more information, please follow other related articles on the PHP Chinese website!