0%

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

Sign in Sign up

Select all text on single clickBack

HTML

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

  • Crazy nav highlighter plugin

    Style your menu selection

    • 295
    • 6
    • 295
    • facebook icon
    • twitter icon
    • google plus
  • Css3 image blending like photoshop

    CSS3 blend mode blends two background simultaneously like Photoshop blending.

    • 227
    • 4
    • 227
    • facebook icon
    • twitter icon
    • google plus
  • Load images visible to user after page load

    Load only those image which is visible to visitor

    • 299
    • 8
    • 299
    • 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
Username
Password