Sunday, October 12, 2025
Latest:
  • German Pronouns with Nominative, Accusative, and Dative cases
  • German articles for the nominative, accusative, and dative cases
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
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 is spread syntax? Explain with example

May 11, 2019 beroza

Facade design pattern

December 24, 2023 beroza

Job for apache2.service failed. See “systemctl status apache2.service” and “journalctl -xe” for details.

May 24, 2020 beroza

Useful Java basic tips for developers

February 26, 2019 beroza

Enforce the singleton property with a private constructor or an enum type

January 21, 2020 beroza

What are the differences between IP address 0.0.0.0 and 127.0.0.1?

December 4, 2019 beroza

Find Resultant Array After Removing Anagrams

June 12, 2023 beroza

Err:1 ec2.archive.ubuntu.com bionic InRelease Temporary failure

June 5, 2020 beroza

What is Apache Kafka? Why should we use Kafka?

November 25, 2023 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.