JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://rangy.googlecode.com/svn/trunk/dev/rangy-core.js"></script>
<iframe id='iframe' src='http://wordpress.com' width='100%' height='300px' frameborder='1'>Salut c'est un texte</iframe>
<input id='text' type='text' />
<button>Grab and Wrap - Iframe</button>

JavaScript

$(function () {
    $('button').click(function () {
        window = $('iframe')[0].contentWindow.window || $('iframe')[0].contentWindow.document;
        var range = rangy.createRange(window);                
        var selection = rangy.getSelection(window);
        alert(selection);   
    });
});