js滚动条置顶
1、Element.scrollIntoView() 方法讓當前的元素滾動到瀏覽器窗口的可視區域內。
? ? ? 如果為true,元素的頂端將和其所在滾動區的可視區域的頂端對齊。
? ? ?如果為false,元素的底端將和其所在滾動區的可視區域的底端對齊。
el.on('focus', '#suggestionContent', function () {var target = this;target.scrollIntoView(true); }); el.on('blur', '#suggestionContent', function () {// document.body.scrollTop = 0;var target = this;target.scrollIntoView(false); });2、設置document.body.scrollTop(注意不要用微信工具打印scrollTop,因為無法彈出虛擬鍵盤)
el.on('blur', '#suggestionContent', function () {document.body.scrollTop = 0; });總結
- 上一篇: 支持外链的免费相册地址集合
- 下一篇: 为什么支付宝跨行转账可以不收费?支付宝为