ivana_andreevska

Dynamic Placeholder

Jan 8th, 2022
1,512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Title</title>
  6.     <link rel="stylesheet" href="jquery_ui.css">
  7.     <script src="jquery.js"></script>
  8.     <script src="jquery-ui.js"></script>
  9.     <link rel="stylesheet" href="style.css">
  10. </head>
  11. <body>
  12. <div id="container">
  13.     <label>Enter your name</label>
  14.     <input id="fname" type="text" placeholder="First name">
  15.     <input id="lname" type="text" placeholder="Last name">
  16.     <p></p>
  17.     <button id="submit">Submit</button>
  18.     <button id="reset">Reset</button>
  19. </div>
  20. <script src="main.js"></script>
  21. </body>
  22. </html>
  23.  
  24.  
  25. #container{
  26.     margin:20px auto;
  27.     width: 700px;
  28.     height:400px;
  29. }
  30. label,input,p{
  31.     font-size: 20px;
  32.  
  33. }
  34. button{
  35.     font-size: 20px;
  36.     border-radius:5px;
  37.     outline: none;
  38.     margin-top: 10px;
  39. }
  40.  
  41. $(document).ready(function (){
  42.     $("#submit").click(function (){
  43.         $("p").show().html("Welcome " + $("#fname").val() + " " + $("#lname").val() +"!");
  44.     });
  45.  
  46.  
  47.     $("#reset").click(function (){
  48.         $("p").hide();
  49.         $("#fname").val("").attr("placeholder" ,"First name");
  50.         $("#lname").val("").attr("placeholder" ,"Last Name");
  51.     })
  52.  
  53. })
Advertisement
Add Comment
Please, Sign In to add comment