Thursday, March 4, 2021
Latest:
  • Reactjs: Nothing was returned from render
  • Name of insects in English
  • Musical instrument Names.
  • Names of different trees.
  • Things we should do before buying a Apple MacBook
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

Share
  • ← What is interface in Java? What are the differences between interface and class?
  • Mac OS X useful tips and tricks for users →

You May Also Like

Bind for 0.0.0.0:8080 failed: port is already allocated

October 17, 2020 beroza 0

Advanced CSS interview questions part 2

August 26, 2019 beroza 0

Disk usage related useful linux command

April 18, 2019 beroza 0

What does /dev/sda means in Linux?

January 4, 2019 beroza 0

Always override hashcode when you override equals

February 5, 2020 beroza 0

What are the WordPress REST API endpoints ?

July 4, 2019 beroza 0

Prefer try-with-resources to try-finally in Java

January 22, 2020 beroza 0

How to make dynamic variable names in Java?

May 8, 2020 beroza 0

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

February 28, 2020 beroza 0
Health benefits delicious fruit Cherry
Health benefits of Spring Onion
How to get rid of bad breath?
Lettuce leaves health benefits
Best foods that are high in Zinc
Which foods are high in magnesium? How much magnesium is better to take daily?
Health benefits of Capsicum
Health Benefits of Radish
Spinach Health Benefits
Health benefits of Cabbage
Excessive sugar intake is harmful to the kidneys and liver
Seim bean or lablab bean health benefits
Health benefits of Kohlrabi
Health benefits of Olives
Health benefits of Cauliflower
Health benefits of green peas
Health benefits of Coriander
Health benefits of Broccoli
Health benefits of Basil Seeds (Tokma, Sabja Seeds, Tukmaria)
Health benefits of Carrots
Health benefits of Rambai fruits
How healthy is our weight according to our height?
Health benefits of Black Tea
Health benefits of Baking soda
Basil leaves or Tulsi leaves health benefits

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 © 2021 Upokary. All rights reserved.