How to pass value from html to javascript value?

In this tutorial learn how to pass input value to pass to javascript. Pass value from html to javascript using a input type with blur event, pass value from html to javascript  and get value in function with javascript  with display in a alert box.

Create a Html file and add input type then create a javascript function with get email value

like function passvalue(email)  {}


Example  Index.html


<!DOCTYPE html>
<html lang="en">
<head>

  <meta charset="utf-8">
  <title>Pass value to javascript</title>

</head>

<body style="text-align:center">

<h1> Pass Value to Javascript</h1>

<!--  here we add method so i added onblue means leave pointer --> 

<input type="email" name="email"  onblur="passvalue(this);" />


<input type="email" name="value" />

</body>
</html>

<script type="text/javascript">



function passvalue(emailField){
        
alert(emailField.value) ;
              
}
</script>


please watch video how it works also




No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...