JSFiddle - React, Tailwind, and code Playground

by cancerbero_sgx

HTML

<button id="printSelect">printSelect</button>
<div id="example-one" contenteditable="true">
    <p>Everything contained <b>within</b> this div is editable in any browser including old IE. <a href="http://html5doctor.com/the-contenteditable-attribute/">A nice article</a> </p>
</div>

JavaScript

function getSelectionText() {
    var text = "";
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != "Control") {
        text = document.selection.createRange().text;
    }
    return text;
}

jQuery('#printSelect').click(function(){
    console.log(window.getSelection())
});