js滚动条置顶
1、Element.scrollIntoView() 方法讓當(dāng)前的元素滾動(dòng)到瀏覽器窗口的可視區(qū)域內(nèi)。
? ? ? 如果為true,元素的頂端將和其所在滾動(dòng)區(qū)的可視區(qū)域的頂端對(duì)齊。
? ? ?如果為false,元素的底端將和其所在滾動(dòng)區(qū)的可視區(qū)域的底端對(duì)齊。
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、設(shè)置document.body.scrollTop(注意不要用微信工具打印scrollTop,因?yàn)闊o(wú)法彈出虛擬鍵盤(pán))
el.on('blur', '#suggestionContent', function () {document.body.scrollTop = 0; });總結(jié)
- 上一篇: 支持外链的免费相册地址集合
- 下一篇: 为什么支付宝跨行转账可以不收费?支付宝为