function copy(obj) { try { if (obj) selectContent(obj) document.execCommand('copy') // clears the current selection window.getSelection().removeAllRanges() } catch (err) { console.log(err) } }