0

Hi I want to check whether the value of textbox is selected or not using jquery.

I want like if textbox value is already selected then wants to deselect the text otherwise select.

Please give me solution for this.

3
  • you'll need to find a suitable jQuery plugin. Commented Nov 11, 2010 at 15:22
  • 1
    Rather than just asking someone to write the code for you, could you mention what you have tried? Commented Nov 11, 2010 at 15:23
  • In my case : onfocus event of textbox i have selected the textbox value usig $(this).select() and on the click event of textbox i want to check if the text is selected then deselect the text and place the cursor on the text box other wise select the textbox value Commented Nov 11, 2010 at 15:34

3 Answers 3

1

It appears the the $("input").select(); is able to detect if text is selected.

I'm not exactly sure what you want to accomplish, but you may want to view http://api.jquery.com/select/ for a basic demo of the functionality. Feel free to provide more details on how you want to implement this, and I'll be happy to try and build onto the demo.

Sign up to request clarification or add additional context in comments.

Comments

0

I think this might be up the the browser to handle - not sure if every browser handles text selection in inputs the same way.

You could however check for focus and blur events, are you familiar with these?

Comments

0

There's a plugin which will detect whether it is selected: http://plugins.jquery.com/project/selectedText. As selecting text, I'm not sure.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.