Giter VIP home page Giter VIP logo

chinesepyjs's Introduction

ChinesePYJs

ChinesePYJs

一.使用js将中文汉字转拼音类库

ChinesePY.js

使用方法自己研究

二.js简单实现汉字转成拼音的功能

最近项目需要一个功能,实现汉字转拼音功能,具体比如说输入一个“你好”,同时带出对应拼音“NiHao”,在此做一下记录

1、首先引入两个文件
    <script src="jquery.min.js"></script>
    <script src="Convert_Pinyin.js"></script>
2、html设计
 <body>
        <div>         
             输入名称:<input type="text" id="chinaName"  onBlur="ConvertName()" />  <br/>  
             全写拼音:<input type="text" id="fullName" /> <br/> 
             简写拼音:<input type="text" id="easyName" /> <br/> 
        </div>    
 </body>
3、js方法
<script>
       var ConvertName = function(){    
            var chinaName = $('#chinaName').val();    
            //获取全写拼音(调用js中方法)        
            var fullName = pinyin.getFullChars(chinaName);
            //获取简写拼音(调用js中方法)
            var easyName = pinyin.getCamelChars(chinaName);    
            //给两个文本框赋值    
            $('#fullName').val(fullName);
            $('#easyName').val(easyName);
       }
</script>

chinesepyjs's People

Contributors

majiameng avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.