Linked Questions
127 questions linked to/from Selecting text in an element (akin to highlighting with your mouse)
0 votes
1 answer
2k views
highlight text inside a div or span using typescript and jquery [duplicate]
I am trying to highlight the text inside a div / span automatically when the page loads. I am able to highlight text in a read-only textbox but, the text inside a div / span, is not working. I am ...
-1 votes
1 answer
1k views
Make single line in div selected when clicked [duplicate]
I wish to make a single line in a div highlighted when clicked (not the whole div selected) I can use jquery or javascript as needed. The div new lines are separated by br tag. <div class="...
0 votes
1 answer
404 views
How can I select all text in a element? [duplicate]
How can I select all text in an element? <div class="wrapper"> <div class="content">Lorem ipsum dolor sit amet.</div> </div> "Wrapper" is an ElementRef. How can I select ...
0 votes
2 answers
522 views
How can I know when the user selects a paragraph? [duplicate]
I want to perform an action when the user selects any text at the page. I tried something like this: var selObj; document.querySelector("p").onselect = function(){ selObj = window....
0 votes
0 answers
305 views
Javascript Trigger Click with CSS user-select: all [duplicate]
I am trying to create a button that will assign a class to a div that wrap a bunch of html elements for the purpose of manually selecting and copying what is selected on the browser "ctrl-c". I have ...
0 votes
1 answer
127 views
Have user selection a certain point of text input with javascript/jquery [duplicate]
I have a text input. <input type="text" id="foo" name="bar" value="11 Minutes"/> I want it so when the user clicks on the input, that the user's "Cursor" or "Selector" is after the 11, not ...
0 votes
0 answers
140 views
How to use jQuery Select on a <code> element or <blockquote> element? [duplicate]
I am trying to select all the text with a <code> or HTML element. I have tried a lot of things but I think that jQuery .select() only works for input boxes. jQuery('code').click(function () { ...
0 votes
0 answers
36 views
How to select the textContent of copy event and how to use it before doing copy event? [duplicate]
How can I select textcontent before it is copied to the clipboard? Here is an idea of selecting with one click: https://stackoverflow.com/a/1173319. But this is an other code with id selector. I only ...
0 votes
0 answers
33 views
How can create a Selection in the browser in JavaScript? [duplicate]
The Selection API allows me to get the current selection with window.getSelection() and edit the selection with selection.modify('extend', 'backward', 'character'); to, for example, go back a ...
133 votes
6 answers
127k views
jQuery - select all text from a textarea
How can I make it so when you click inside a textarea, its entire content gets selected? And eventually when you click again, to deselect it.
35 votes
4 answers
45k views
How to select the text of a span on click?
I am looking for a way to select the text inside a span using jquery when the text is clicked on. For example in the html snippet below, I want the text "\apples\oranges\pears" to become selected ...
42 votes
5 answers
36k views
How to select all text in contenteditable div?
Before this is flagged as a duplicate, I want you to realize that no one has actually provided a good answer for this specific question. In select all text in contenteditable div when it focus/click, ...
25 votes
6 answers
57k views
JavaScript copy to clipboard not working
I have a function in my script that gives me an error. The function purpose is to copy text from static panel(not textbox or input) with onClick event. Uncaught TypeError: copyText.select is not a ...
22 votes
6 answers
1k views
How can I highlight a word/term quicker and smarter?
I have some text: <p class="drag">Hello world, Attack on Titan season two!</p> Currently, if a user wants to highlight a word/term with the cursor, they will click and drag, letter by ...
13 votes
8 answers
36k views
Use jQuery to auto select text inside a span tag when clicked
I have a div which contains a series of span tags, each containing a string of text. I'd like to attach a jQuery click event to all of the spans so that when the text inside any span is clicked, the ...