Thursday, June 25, 2026
Latest:
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
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

Why useState is asynchronous in ReactJS?

January 1, 2021 beroza

What are the reasons of Kafka rebalancing?

May 7, 2020 beroza

How to dynamically add property of nested object JavaScript

July 29, 2021 beroza

Why prefer interfaces to abstract classes?

March 11, 2020 beroza

Redistribute Characters to Make All Strings Equal

December 30, 2022 beroza

Obey the general contract when overriding equals in Java

February 6, 2020 beroza

1Mbps connection but download speed is showing 100KBps, why?

December 20, 2020 beroza

What is Type Assertions in TypeScript?

November 11, 2021 beroza

Command design pattern

February 2, 2025 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 © 2026 Upokary. All rights reserved.