简体   繁体   中英

Input a text into a text field, click a button and get the result on the page (JQuery)

I am trying to make a skill for the amazon echo (with js and JQuery) but I am a little stuck. I want to enter 2 things in 2 different text fields on a website. This works. $('#Field1').val("Test Text"); $('#Field2').val("Test Text 2");

Eg Field1: Test Text --- Field2: Test Text 2

Then I want to click a button on this Website. This doesn't work and I don't know how to do it.

After pressing the button I want to get the results that show up on the website. Getting the results (when using manual input, so clicking the button by hand) works. I hope you guys get me and can help me!

Greetings Fabian

It depends on the form.

HTMLElement.click() works with input types of "button" and "submit".

HTMLFormElement.submit() submits a form.

jQuery also has a .trigger() method and aliases like .click() if you need to trigger specific jQuery events.

You'll need to understand what elements and event listeners the form has and use the appropriate methods. Note that these techniques have caveats and restrictions because of browser compatibility and security risks for the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM