Sunday, December 7, 2025
Latest:
  • 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?
  • How Spring framework resolves circular dependencies?
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

How to get element by class name in JavaScript?

June 10, 2021 beroza

How to add multiple language support in ReactJS with i18next and react-i18next?

September 30, 2020 beroza

How to resize SVG type image?

May 30, 2021 beroza

Write a Program to Display Table of Food Orders in a Restaurant

January 14, 2023 beroza

What is OAuth 2.0?

January 9, 2022 beroza

How to convert timestamp to date object in JavaScript?

April 15, 2021 beroza

Who is listening on a given TCP port on Mac?

September 16, 2021 beroza

What is a consumer group in Kafka?

April 26, 2020 beroza

Write a program to generate a string with characters that have odd counts

June 8, 2022 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.