Search Results

Search found 1 results on 1 pages for 'lethalbody'.

Page 1/1 | 1 

  • getSelection & surroundContents across multiple tags

    - by lethalbody
    Hi, I've got a script that changes the background colour of text that has been selected. However i'm encountering an issue when the text is selected across multiple elements/tags. The code that i've got is: var text = window.getSelection().getRangeAt(0); var colour = document.createElement("hlight"); colour.style.backgroundColor = "Yellow"; text.surroundContents(colour); And the error being output is: Error: The boundary-points of a range does not meet specific requirements. = NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR Line: 7 I believe this is to do with the getRange() function though i'm not too sure how to proceed since I am a beginner at javascript. Is there any other way I can replicate what I am trying to achieve? Many thanks.

    Read the article

1