-1

What is meaning of following code, I want to convert in to jquery for browser compatibility.

document.selection.createRange().text
  • Nor sure if it does everything you need, but take a look here: http://madapaja.github.io/jquery.selection/ – Peter B Jun 26 '17 at 07:27
  • Possible duplicate of [document.selection.createRange() not working in chrome and safari](https://stackoverflow.com/questions/7021497/document-selection-createrange-not-working-in-chrome-and-safari) – Kaushik Thanki Jun 26 '17 at 09:15

1 Answers1

1

document.selection is an IE-specific legacy way to get text that the user has "selected" (highlighted with the mouse) on a web page.

It's now deprecated in favour of the standards-based document.getSelection() - see the MDN documentation for more info.

There are already jQuery plugins that make this cross-browser, e.g jquery-textrange

danwellman
  • 9,068
  • 8
  • 60
  • 88