JSFiddle - React, Tailwind, and code Playground

HTML

<p>Fruit <span class="unc_path">\\apples\oranges\pears</span></p>

JavaScript

$('.unc_path').click(function (){
    var range, selection;
    
    if (window.getSelection && document.createRange) {
        selection = window.getSelection();
        range = document.createRange();
        range.selectNodeContents($(this)[0]);
        selection.removeAllRanges();
        selection.addRange(range);
    } else if (document.selection && document.body.createTextRange) {
        range = document.body.createTextRange();
        range.moveToElementText($(this)[0]);
        range.select();
    }
});