Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
XML
Hello folks,
                I have an issue that I want to High lite a specific  text according to  its X And Y position in browser. for Example
 <div>
<h4>
Hi, This is your Invoice No 1234567890
</h4>
</div>
This Text is under<div> <h4> tag. If i want to High lite  dynamically a specific X and Y position of <h4> then how it is possible using pure javascript.Please note  that need only in Javascript not in Jquery. I am not using any-kind of jquery.i f you have any code or idea to do this  then i am really appreciated.
Thank in Advance
KP Singh Chundawat
Posted
Comments
Kornfeld Eliyahu Peter 16-Dec-14 7:54am    
Please refine your sample? What do you mean by X-Y position? Do you have a specific sample?
KP Singh Chundawat 16-Dec-14 8:05am    
Ok fine ...
This is My Javascript function
function changeColor(startinx,endindex) {
elem = document.elementFromPoint(startinx, endindex);
elem.style.color = "Red";
}

And This is My HTML Code
<div id="code" >

This is your invoice Number 123456789

<br />

This is your invoice Number 123456789

<br />

This is your invoice Number 123456789

<br />
</div>
<br />
<input type="button" value="Mark!" >
</body>

But It is Highlighting full text i dont want to Hightlite full text i want to need highlight a Specific value which is positioning between X&Y .
Thanks
Kornfeld Eliyahu Peter 16-Dec-14 8:09am    
elmentFromPoint is working on X,Y PIXEL!!! coordinates!!! so your endindex variable will be interpreted as Y coordinate!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900