$('button').on('click', function(){
let selection = document.getSelection().toString().trim();
document.execCommand('createLink', true, selection);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class = 'parent' contentEditable = 'true'>
Lorem ipsum dolor sit amet google.com
</div>
<br>
<button>CLICK</button>
So make a selection from google.com
and click the button.
google.com
becames blue as it is a link, but click on it - doesn't work.
How to get a real clickable link from google.com
with target = _blank
, and cursor = pointer
, if possible?