0

I would like simulate the event of clicking on an input element, typing a string and then pressing enter. The function I'm looking for should be given a string and write it to an html element. Does anyone know how I could do that? Here's the element: (the normal (second) element is what should be selected and written to)


<ion-input autocapitalize="off" autocomplete="off" autocorrect="off"
class="answerInput input input-md ng-valid ng-touched ng-dirty" id="answerInput"
name="answerInput" spellcheck="false" text-center="" type="text" ng-reflect-
name="answerInput"ng-reflect-model="" ng-reflect-type="text" ng-reflect-
autocomplete="off" ng-reflect-autocorrect="off"><!--bindings={
  "ng-reflect-ng-if": "true"
}-->
<input class="text-input text-input-md" dir="auto" ng-reflect-klass="text-input"
ng-reflect-ng-class="text-input-md" type="text" aria-labelledby="lbl-1" 
autocomplete="off" autocorrect="off" placeholder="" autocapitalize="off"
name="answerInput" spellcheck="false" text-center="" ng-reflect-
name="answerInput" ng-reflect-model="" ng-reflect-type="text" ng-reflect-
autocomplete="off" ng-reflect-autocorrect="off">
<!--bindings={
  "ng-reflect-ng-if": "false"
}--><!--bindings={
  "ng-reflect-ng-if": "false"
}--><!--bindings={
  "ng-reflect-ng-if": "false"
}--></ion-input>

I already tried selecting it with:

var input = getElementByClassName('text-input text-input-md');
input.focus();
input.select();

It tells me select is not a function

derTier
  • 11
  • 2
  • There is no built in global function named `getElementByClassName`. It should be telling you that as well. – Heretic Monkey May 12 '20 at 19:13
  • Does this answer your question? [jquery (or pure js) simulate enter key pressed for testing](https://stackoverflow.com/questions/3276794/jquery-or-pure-js-simulate-enter-key-pressed-for-testing) – Heretic Monkey May 12 '20 at 19:15

0 Answers0