Implementation effect:
Figure I:
Figure II:
In this example, the Chinese character string "Take care of Yourself", with three words being pronunciation, so the alert dialog box shows a combination of multiple pronunciations;
How to achieve it?
How to achieve through Pinyin first letter quickly find the content of Chinese in the page?
The principle of the process is this: for example, to make a quick search of some names, when the page is loaded, set up an index of all the names, generate the corresponding relationship between the first letter and the name of pinyin; then listen for keyboard events, and when the user presses the keyboard, according to which letter the key is worth, Then traverse the index to see if the same phonetic initials exist;
It also implements the ability to find by letter combination, the principle is this: when the user button, we record the button time, if two consecutive key intervals less than a second, it is considered a combination of query, the current key value added before the key value, not much said, on the code!
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/