Radu
Radu

Reputation: 8699

Jquery .select() for other html elements

How can I leverage the same functionality of .select() but for elements other textboxes such as list elements?

Edit: To clarify, I'm not looking to retrieve the selected text, I want to make it such that a key combo will trigger the selection of a list elements for example.

Upvotes: 1

Views: 108

Answers (2)

Breezer
Breezer

Reputation: 10490

Well while w8ting for a good answer i found this plugin that seems to work perfectly

http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html

if you want to do the selecting part there is another plugin here

http://www.ryantetek.com/2010/02/selecting-text-inside-html-elements-with-jquery/

Upvotes: 1

Lee
Lee

Reputation: 13542

It's not a direct approach, but you can listen for mouseup, then check to see if there's a selection. It's not exactly what you asked for, but it might get you close.

Here's an example on jsFiddle

Upvotes: 1

Related Questions