0

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 () { jQuery(this).select(); // text should now be highlighted in the browser }); 

My HTML

<code>.alpha{}</code> <code>Some other code element on the page.</code> <blockquote>A famous quote</blockquote> 

It should select and highlight the text

enter image description here

5
  • What do mean by highlighted? "selected"? Commented Feb 14, 2017 at 7:23
  • 1
    Here's Demo of the code from an answer in the linked question. Commented Feb 14, 2017 at 7:27
  • @Tushar thanks for taking the time to do that demo +1 Commented Feb 14, 2017 at 7:32
  • Can you please make an answer @Tushar so I can reward you. Commented Mar 8, 2017 at 4:13
  • No. The question is closed so no more answers can be added. Also, it is already asked. I've just created demo from the answer on linked question. You can upvote that answer. Commented Mar 8, 2017 at 4:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.