Saturday, November 15, 2025
Latest:
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
  • How Spring framework resolves circular dependencies?
  • German Pronouns with Nominative, Accusative, and Dative cases
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

How to get the selected text from a HTML document using JavaScript?

Published: February 22, 2020Last updated: July 22, 2020 JavaScript

The use case was quite simple. We had an HTML document where the user was selecting a block of text. We wanted to get that selected text using JavaScript. Following the code segment that does that in JavaScript:

window.getSelection().toString

Source:
Selected text JavaScript

Get selection JavaScript

You May Also Like

What are the differences between application server and a servlet container?

November 25, 2019 beroza

Write a Program to Find Most Common Word

January 14, 2023 beroza

Average Salary Excluding the Minimum and Maximum Salary

May 28, 2023 beroza

Topics to cover before coding interview

November 6, 2022 beroza

Avoid creating unnecessary objects in java

January 22, 2020 beroza

How to access react context outside of render function in ReactJS?

February 28, 2020 beroza

What are the rules of determining value of keyword “this” in JavaScript?

March 12, 2019 beroza

Write a Program to Find Number of Senior Citizens

May 28, 2023 beroza

What is an arrow function and why use arrow function in JavaScript?

March 18, 2019 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2025 Upokary. All rights reserved.