-3

So i did found one really good highlighter. The Problem With this one is that it cant select more then one element.

function changeBGr() {

  var sel = window.getSelection ? window.getSelection() : document.selection.createRange(); //FF:IE 
  if(sel.getRangeAt){ // thats for FF
    var range = sel.getRangeAt(0);
    var newNode = document.createElement("span");
    newNode.setAttribute('style', 'background: red');
    range.surroundContents(newNode);
  } 
  else { //and thats for IE7
  sel.pasteHTML('<span style="background:red">'+sel.htmlText+'</span>');
  }
}

i saw this one too.Change CSS of selected text using Javascript but i could t make it work :S (Yeah i know i noob) Any ideas?

Community
  • 1
  • 1

1 Answers1

3

This looks like a good starting point for what you're after: http://www.codetoad.com/javascript_get_selected_text.asp

ilivewithian
  • 19,476
  • 19
  • 103
  • 165