Friday, May 9, 2025
Latest:
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
  • German words with gender
  • When to use einen and keinen in German?
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, 2020JavaScript

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

In which order static initialisation block and constructor run in java?

September 16, 2019 beroza

How to access react context outside of render function in ReactJS?

February 28, 2020 beroza

JavaScript arrow function related interview questions

March 18, 2019 beroza

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

January 4, 2019 beroza

Write a Program to Find Lexicographically Smallest Palindrome

June 3, 2023 beroza

What is memory leak? How to avoid memory leak in JavaScript?

August 14, 2021 beroza

Search Suggestions System

December 29, 2022 beroza

Write a Program to Find the Distinct Difference Array

June 3, 2023 beroza

Reset form fields, set of fields using jQuery

December 11, 2018 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

Languages

  • EnglishEnglish
  • বাংলাবাংলা

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.