Hyory Liu
JavaScript 获取选中文字
2024-04-21
<html> <head> <meta charset=“UTF-8”> <meta name=“viewport” content=“width=device-width, initial-scale=1.0”> <title>获取选中文字</title> </head> <body> <input id=“inputText” onselect=“logSelection(event)”> <button onclick=“obtain()“>获取</button> <p>被选中的文字为:<span id=“selectedText”></span></p> <script> var selectedText = ""; var selectionInfo = { x: 0, y: 0 }; function logSelection(event) { const selection = event.target.value.substring(event.target.selectionStart, event.target.selectionEnd); selectedText = selection; selectionInfo = { x: event.target.selectionStart, y: event.target.selectionEnd }; } function obtain() { document.querySelector(“#selectedText”).innerText = selectedText; document.getElementById(“inputText”).focus(); } </script> </body> </html>
207 字
|
1 分钟
如何设计一个沉浸感非常强的页面
2024-04-04
无论是网页,还是 APP 的 UI,甚至是海报,沉浸感都非常重要,强烈的沉浸感不仅可以给人眼前一亮的感觉,也可以让用户快速进入你想要的状态甚至情绪。
580 字
|
3 分钟
手机上的“VScode”到底怎么样?
2024-03-21
以往,我在手机上编程,对于不同的语言使用不同的 IDE,比如 Python 用 Pydroid,前端用 SpckEditer 等。
514 字
|
3 分钟