简体   繁体   中英

have an HTML document with a linked Javascript I am trying to add an alert message when a submit button is clicked. How do I do this?

I have a form and within the form on my HTML i have a submit button. I want an alert to pop up when clicked that says Thank you for contacting us we will respond shortly.

Like @Ele said.. this can be found in a ton of places.. but its very simple.. Just do the following:

This is in the html:

<button onClick="MyFunction()">Submit</button>

This is the JavaScript:

<script>
function MyFunction() {
    alert("Thank you for contacting us, we will respond shortly.");
}
</script>

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