输入框多了的话就模拟 ,先删除再创建再绑定
HTML页面
<input type="text" name="form-username" id="form-account">
JS页面
function Div(name) { var my = document.getElementById(name); if (my != null) my.parentNode.removeChild(my); } $(function () { //点击输入框 $("input[name='form-username']").click (function () { Div("keyboard") //创建一个div var my = document.createElement("div"); //添加到页面 document.body.appendChild(my); my.id = "keyboard"; my.className = "softkeys center-block"; var attr = document.getElementById("keyboard"); attr.setAttribute("data-target", "input[id='form-account']") $('.softkeys').softkeys({ target: $('.softkeys').data('target'), layout: [ [ ['1', '!'], ['2', '@'], ['3', '#'], ], ] }); }) //以此类推 })回复