0

As opposed to this question (https://stackoverflow.com/revisions/3368578/1), I DO want to print text in a text box on the loading of a page.

I don't know much about jQuery so I'm not even sure this is possible. I want to set focus on a field onload, and then perform a backspace keystroke in that field (not simulate it). This seems on track(https://stackoverflow.com/a/16122568/3748951), but I don't know how to trigger the event and assign the value to the textbox simply onload. I would greatly appreciate any help.

Community
  • 1
  • 1

1 Answers1

1

I guess that's what you want, don't need trigger simulate a backspace :

$(document).ready(function(){
    //Select your input here
    $('input').val(function(_, old){
        return old.slice(0, -1); //Remove the last character
    }).focus()
})
Karl-André Gagnon
  • 33,662
  • 5
  • 50
  • 75