在前台直接添加onkeypress可以实现.
<input id="CurrPage" type="text" style="text-align:center;width:40px;" onkeypress="if (event.keyCode == 13) searchPage()" />
后来修改成在js文件中添加input控件, 并添加onkeypress属性, 没有效果了
var temp5 = document.createElement("input");
temp5.type = "text";
temp5.id = "CurrPage";
temp5.style = "text-align:center;width:40px;"
temp5.onkeypress = "if (event.keyCode == 13) searchPage();";
temp5.value = curPage;
div.appendChild(temp5);
请各位大神帮忙看看, 需要怎么修改才能实现相同的效果, 谢谢!