General JS functionality

General JS functionality

  
Hi All,

For inputfields I want to following functionality:
When I click with the mouse(get focus) in the inputfield I want the value of that inputfield selected.
The reason for this is that then the users doesn't need to backspace the current value or selected it manually.

I know I can do it by writing an onclick event for each input field, but is there a way to write a script to implant this functionality for all inputfields?

Thanks!
You just need to use a jquery selector to find all inputs and bind your function to them: https://api.jquery.com/input-selector/

would be something like this:

$( ":input" ).focus(function( event ) {
//your code here
});

You can also use the focus selector to find only the elements that are focused and work with them.
https://api.jquery.com/focus-selector/

Hope it helps,