Saturday, April 4, 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

org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution

January 4, 2019 beroza

How to set default value for items of List in Java?

May 7, 2020 beroza

Count the Number of Vowel Strings in Range

May 28, 2023 beroza

JavaScript topics to cover before interview

January 1, 2019 beroza

What is a nested class? Builder pattern with nested class

October 3, 2024 beroza

Write a Program to Find Number of Unequal Triplets in Array

January 16, 2023 beroza

How to stop adding, modifying and deleting an object’s properties?

August 7, 2021 beroza

How to visually hide element using CSS?

August 15, 2021 Avijit Paul

ERROR: Permission to repository.git denied to username. fatal: The remote end hung up unexpectedly

August 31, 2019 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.