Sunday, November 15, 2026
Latest:
  • Präsentation für b1
  • Verb “werden” Konjugation
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
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 set environment variables on Mac OS and Ubuntu?

July 3, 2020 beroza

How to override WooCommerce default template file?

January 6, 2020 beroza

Should we commit yarn.lock and package-lock.json files?

July 2, 2020 beroza

Useful regular expressions that every developer should know

July 6, 2020 beroza

How to reuse a parameter in String.format?

December 6, 2019 beroza

How to check if an element is visible in the current viewport as we scroll?

July 8, 2020 beroza

How to write a linux service for running spring boot application?

October 30, 2019 beroza

The following SDK component was not installed: sys-img-x86-addon-google_apis-google-21

December 4, 2018 beroza

Write a Program to Find Subarrays With Equal Sum

May 14, 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 © 2026 Upokary. All rights reserved.