JS小技巧

 function fy() {
        var pageNo = document.getElementById("pageNo").value;
        if ( 1 <= pageNo && pageNo <= ${PAGE_SESSION.allPageNo}) {
            window.location.href="/crm/crmservlet?method=findAllCustomer&pageNo="+pageNo;
        } else {
            alert("请输入正确的页码!");
            var pageNoElement = document.getElementById("pageNo");
            pageNoElement.focus();
            pageNoElement.select();
        }

将光标定位到inputID处(focus()),并选中原内容(select())

 

原文地址:https://www.cnblogs.com/SkyGood/p/4046884.html