Why my html page is reloading when I am clicking on login? when I am inputting the value and than I click on login my html page is reloading on that same page can anyone can tell how to fix it? you all can also check my code and please tell how can I fix this problem in my project
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Contact Us</title>
<link rel="stylesheet" href="style.css">
<script src="script2.js"></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/@emailjs/browserdeeenos564513/dist/email.min.js"
></script>
<script type="text/javascript">
(function () {
emailjs.init("w4u9263ndvjlj0MFL");
})();
</script>
</head>
<body>
<div id="wrapper">
<div class="container">
<div class="phone-app-demo"></div>
<div class="form-data">
<form id="myForm">
<div class="logo">
<img src="./images/logo.png" alt="logo">
</div>
<input type="text" placeholder="Phone number, username, or email" id="email">
<input type="password" placeholder="Password" id="name">
<button class="form-btn" onclick="sendMail()">Log in</button>
<span class="has-separator">Or</span>
<a class="facebook-login" href="#">
<i class="fab fa-facebook-square"></i> Log in with Facebook
</a>
<a class="password-reset" href="#">Forgot password?</a>
</form>
<div class="sign-up">
Don't have an account? <a href="#">Sign up</a>
</div>
<div class="get-the-app">
<span>Get the app.</span>
<div class="badges">
<img src="./images/app-store.png" alt="app-store badge">
<img src="./images/google-play.png" alt="google-play badge">
</div>
</div>
</div>
</div>
</div>
</body>
</html>
a
button
has a default behaviour of submitting a form – to prevent that add atype
attribute, such astype='button'
– Professor Abronsius
48 mins ago
Have you tried adding the
type
attribute as per the above comment?– Professor Abronsius
43 mins ago
You could go onto StackOverflow and search for
[javascript] how do I stop my page reloading when a button is clicked