Is there any way to get the text before cursor?

Using javascript is it possible to get the text that comes before the cursor?

In the image below I need the following text to be returned: "This is a sample text, sec" or "This is a sample text, first paragraph. This is a sample text, sec"

It can be the text before the cursor to the beginning of the paragraph or the text before the cursor to the beginning of the document.



Thanks!



5 Replies

SM Suriya Murugan Syncfusion Team October 14, 2021 07:45 AM UTC

Hi Tiago, 

Syncfusion Greetings! 

We have prepared the sample for your requirement. 


1.      In above sample move selection to paragraph start and retrieved text. (Check getText method) 

Documentation link for reference: 

Regards, 
Suriya M. 



TL Tiago Luz October 15, 2021 01:24 PM UTC

Thank you Suriya, this was exactly what i needed!



SM Suriya Murugan Syncfusion Team October 18, 2021 03:22 AM UTC

Hi Tiago, 

Thanks for your update. 

Regards, 
Suriya M. 



CF Carlton Flores November 4, 2021 08:57 AM UTC

Thanks, it worked for me ! techzpod mobdro



KB Kurthis Banu Abdul Majeeth Syncfusion Team November 8, 2021 05:38 AM UTC

Hi Carlton, 

Thanks for your update.  

Regards,  
Kurthis Banu A. 


Loader.
Up arrow icon