Here's some code to add and remove highlights. It's too long to post here practically, so I've made a demo and posted a snippet below. It's not quite ideal because the unhighlight() function doesn't remove span elements inserted by the highlight command, but with a little care this would be a possible addition.
Here's some code to add and remove highlights. It's too long to post here practically, so I've made a demo and posted a snippet below. It's not quite ideal because the unhighlight() function doesn't remove elements inserted by the highlight command, but with a little care this would be a possible addition.
Live demo: jsfiddle.net/timdown/Bvd9d/ Code snippet: function unhighlight(node, colour) { if (!(colour instanceof Colour)) { colour = new Colour(colour); } if (node. NodeType == 1) { var bg = node.style. BackgroundColor; if (bg && colour.
Equals(new Colour(bg))) { node.style. BackgroundColor = ""; } } var child = node. FirstChild; while (child) { unhighlight(child, colour); child = child.
NextSibling; } }.
Useful information. Thanks. – PhoenixJon Nov 12 at 19:06.
You could use CSS instead: EDIT: Update in response to comment and clarification Although, this fails in some browsers (I think it's Firefox) where the element style is changed to the computed style.
1 I think you misunderstand my question. I want to do it dynamically using javascript. – PhoenixJon Nov 10 at 7:54 1 @PhoenixJon this will be dynamic.It'll change the background color of only the text that is selected.
Not using JavaScript, but it'll work like you want it to. – Amaan Nov 10 at 7:55 @Amaan Thanks for your comment.Er.. What I want is when I select the text and press "highlight" button, then the selected text remains highlighted. And again when I pressed "remove" button, highlighted text becomes normal text.
Something like this.. – PhoenixJon Nov 10 at 7:59 Oh. Now I get it. – Amaan Nov 10 at 7:59 In that case I'll update my question in a moment.
– Kolink Nov 10 at 10:06.
And I don't think u'll need to do anything else . All the background color will be restored automatically . – wannabeApro Nov 10 at 8:15 That doesn't works.
– PhoenixJon Nov 10 at 8:28 checked in chrome and firefox browsers console .. works fine .. – wannabeApro Nov 10 at 8:34 He's already using removeAllRanges. The issue is that he's executed the hilitecolor command on a range, and so it now has that, and he wants to remove it later. – T.J.Crowder Nov 10 at 8:47.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.