Monday, March 16, 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

Write a Program to Find Minimum Suffix Flips

January 11, 2023 beroza

CSS special selectors

August 26, 2021 beroza

Write a Program to Find Min Max Game

May 17, 2023 beroza

How to install java on mac using homebrew?

July 29, 2019 beroza

How to render image with srcset and sizes in WordPress?

June 1, 2021 beroza

This material file is bad or corrupted, photoshop

June 14, 2019 beroza

How to clone an EC2 instance in AWS?

November 13, 2019 beroza

How to render and return html using render_to_string in rails?

May 27, 2020 beroza

How to get number of bits set to 1 of a binary number?

November 7, 2021 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.