how to remove the class attribute from the selected text range?


i need to remove class attribute from the selected text(selected text means user will select some range of text by mouse). if the selected text has the class='ansspans', then we need to remove that class for that particular selected text. ( i am using this in gridview, so many rows will be there, so i need to remove class for that particular selected text)

 <span id="sss_ctl00_ctl06_lblAnswerText" class="Label">
      <span>ssss</span><span class="ansspans">assignment</span>submission

  1. if User Selects assignment from the page, which already has class='anspans', then if he click button(to reset highlighted marking), then for that particular selected text, we should remove the class attribute. after clicking the button.


  <span id="sss_ctl00_ctl06_lblAnswerText" class="Label">

here why i am doing this,

  1. Basically user will select some word and mark some word. (marking and highlighting is all done, n working fine ) ( imagine he selects 3 words)
  2. Now user wants to remove the one of the highlighted word, then he selects the word, then click reset button. then for that selected text, class attribute will be removed. which i am facing problem.

Update : Even i tried one of my friends solution like this. JSfiddle - still not working for my page.

A Rangy-specific version of this is solved on the Rangy forum. Code is quite lengthy so not reproduced here.