- 引入js:
encodeToGb2312.js下载地址 - 引用此js后,调用
encodeToGb2312(str)即可。
eg
<input id="q" type="text" />
<input id="button" type="button" value="搜索" />
给以上输入框绑定点击事件,在点击事件中:console.log(encodeToGb2312(str)) (str)是输入框的汉字。
encodeToGb2312.js下载地址encodeToGb2312(str)即可。eg
<input id="q" type="text" />
<input id="button" type="button" value="搜索" />
给以上输入框绑定点击事件,在点击事件中:console.log(encodeToGb2312(str)) (str)是输入框的汉字。

被折叠的 条评论
为什么被折叠?