1、引入样式和依赖js
<link rel="stylesheet" href="./css/mathquill.css"> <link rel="stylesheet" href="./css/keyboard.css"> <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script> <script src="./js/jquery.slimscroll.min.js"></script> <script src="./js/chinese-pynsimpl.js"></script> <script src="./js/mathquill.min.js"></script>
修改键盘样式去keyboard.css里面修改,所有样式都可以随意修改
2、引入键盘逻辑js
<script src="./js/keyboard.js"></script>
功能都写在keyboard.js
(1)配置mathqill.js:
var config={ spaceBehavesLikeTab: true, leftRightIntoCmdGoes: 'up', restrictMismatchedBrackets: true, sumStartsWithNEquals: true, supSubsRequireOperand: true, autoSubscriptNumerals: true, handlers: { edit: function(){ }, }, restrictMismatchedBrackets: true };
可百度mathqill官网自行配置
(2)实例化
var MQ = MathQuill.getInterface(2); var mathField = MQ.MathField($("#txt_latex")[0], config);
其他方法不一一赘述,js里面注释的很清楚,pad端使用不会弹起原生键盘,如果觉得公式不全请自行查找相应latex公式写入页面布局的dom上。