JSFiddle - React, Tailwind, and code Playground
by Dylan Schadeck
HTML
<div id="selectme">
<p>Some text goes here!</p>
<p>Moar text!</p>
<img src="http://placehold.it/50x50" alt="">
</div>
<p>Click me!</p>
JavaScript
function SelectText(element) {
var doc = document
, text = doc.getElementById(element)
, range, selection
;
if (doc.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}
}
$(function() {
$('p').click(function() {
SelectText('selectme');
});
});