0

I am Facing a problem in JavaScript to get html for selected text using range for eg:- i have an html like:-

  <span>demo text</span> 

Now in Chrome when i select the "demo Text" then i want span tag with inner text. I have tried the following code for that but not able to get the desired output in Chrome.

var rangeTemp = selection.getRangeAt(0);      
clonedSelection = rangeTemp.cloneContents();
var div = document.createElement('div');
div.appendChild(clonedSelection);

word = div.innerHTML;

the Above code working fine in IE and Firefox but not in chrome.

Thanks & Regards

Anil

Pavlo
  • 43,301
  • 14
  • 77
  • 113
user987372
  • 19
  • 2
  • 7

0 Answers0