I'm using the inline NicEdit
editors and I want the entire text of the inline editor to be selected on a focus event for easy deletion, since it contains a placeholder text which should be deleted at all times. It is important for the user experience that the placeholder text is selected/highlighted and not just deleted instantly on focus.
Since this is not a <textarea>
the jQuery .select()
method cannot be used for this purpose but maybe there is a workaround?
I appreciate your help.
Asked
Active
Viewed 1,288 times
0
-
This is not a duplicate of the link suggested since this question is not about a ` – Emil Østergård Johansen Apr 19 '17 at 09:15
1 Answers
0
I just grabbed the id and used .empty()
myNicEditor.addEvent('focus', function(e) {
var id = myNicEditor.selectedInstance.e.id;
$("#"+id).empty();
});
Here is a fiddle

Kelly J Andrews
- 5,083
- 1
- 19
- 32
-
Thank you, however the question was how to select/focus the text (which provides a nice user experience), not just deleting the contents. Sorry if this wasn't clear. – Emil Østergård Johansen Apr 19 '17 at 09:16
-
@EmilØstergårdJohansen It took 3.5 years for you to respond to this? LoLz. – Kelly J Andrews Apr 23 '17 at 22:04
-
Haha yeah sorry, I just stumbled over it again and thought I would update it if someone else was looking for it :) – Emil Østergård Johansen Apr 24 '17 at 22:13