Monday, July 27, 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 add script with script tag in ReactJS?

May 31, 2021 beroza

Maximum Value of a String in an Array

December 29, 2022 beroza

Write a program to convert a binary number to decimal number using recursion

November 7, 2022 beroza

How to check a URL is valid or not in JavaScript?

November 28, 2019 beroza

Difference between Jenkins vs Jenkins X

September 4, 2019 beroza

How to install maven in Mac OS?

July 31, 2019 beroza

Bitwise XOR related programming problems

May 31, 2023 beroza

Add new users to an Amazon EC2 Ubuntu instance and allow SSH access

July 22, 2020 beroza

How to visually hide element using CSS?

August 15, 2021 Avijit Paul

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.