0

I'm trying to get the text which we select in the page.I'm displaying the data dynamically on the page.

Code:

//get selection 
var getSelected = function () {
    var t = '';
    if (window.getSelection) {
        t = window.getSelection();
    } else if (document.getSelection) {
        t = document.getSelection();
    } else if (document.selection) {
        t = document.selection.createRange().text;
    }
    return t;
};

$("#text").select(function (eventObject) {
    console.log(getSelected().toString());
});

The data in the page contains in

chapterHTML += '<p id="text"><sup>'+ (i+1) +'</sup>'+ vers.text() +'</p>';

Thanks in Advance.

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
Lucky
  • 425
  • 3
  • 8
  • 19

0 Answers0