Hey! Do you have any query related to front end?

Sign in Sign up

Select all text on single clickBack


Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Code: Copy and paste

//Get dom element as per your choice
var selectableCon = document.getElementsByClassName('selectableCon')[0];

//Take a variable to represent the state of selection
var selectStat = false;

//Set on click event for the DOM
selectableCon.onclick = function(){

	//Set DOM to contentEditable = true to true otherwise.
	this.contentEditable = true;

	//Use execCommand that will execute selection command
	document.execCommand('selectAll', false, null);

	//Set contentEditable to false otherwise user can edit
	this.contentEditable = false;

selectableCon.onblur =function(){
	this.contentEditable = false;
	selectStat= false;

How to comment:

  • Create an account in discuss by clicking on login next to arrow.
  • Create password for discuss and varify your email id, through your mail.
  • Refresh page and comment.

You might also like

  • Copy text to clipboard

    Copy text from browser to your clipboard and paste as per your requirement.

    • 270
    • 2
    • 270
    • facebook icon
    • twitter icon
    • google plus
  • Hanging menu on window scroll

    After scrolling window beyond menu height, a floating bar appears at the top having same menu inside it.

    • 314
    • 12
    • 314
    • facebook icon
    • twitter icon
    • google plus
  • Side pusher hamburger menu

    Side pusher hamburger menu is a better way put more content on the page.

    • 465
    • 8
    • 465
    • facebook icon
    • twitter icon
    • google plus

Latest quries posted

gopa kumarabout 3 years ago

amit singhabout 3 years ago

rahmat aliabout 3 years ago

mandavi tiwariabout 3 years ago

rahul sharmaabout 3 years ago

Ask question
Latest video
Learn Angular
Profile pic
Guest Back