1.0.1 • Published 2 years ago
selection-text v1.0.1
安装
npm install selection-text --save
导入
import 'selection-text'
使用方式
// el: 标签,callback:回调函数
const el = document.createElement('div')
el.innerText = '这是一条很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的信息,我被选中了'
document.appendChild(el)
window.selectionText(el, (data) => {
// 选中的文本:例如'我被选中了'
console.log(data.text)
})
开源协议
ISC