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

  • Characters limit in textarea

    Limit charecters in textarea without extra space.

    • 324
    • 5
    • 324
    • facebook icon
    • twitter icon
    • google plus
  • Single slide respo slider plugin

    Simple jQuery content slider plugin

    • 542
    • 36
    • 542
    • facebook icon
    • twitter icon
    • google plus
  • Load images visible to user after page load

    Load only those image which is visible to visitor

    • 425
    • 8
    • 425
    • facebook icon
    • twitter icon
    • google plus

Latest quries posted

gopa kumarabout 4 years ago

amit singhabout 4 years ago

rahmat aliabout 4 years ago

mandavi tiwariabout 4 years ago

rahul sharmaabout 4 years ago

Ask question
Latest video
Learn Angular
Profile pic
Guest Back