Guest User

Untitled

a guest
Jan 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script>
  4. function func()
  5. {
  6. var elem=document.createElement("input");
  7. document.body.appendChild(elem);
  8. elem.setAttribute('type','text');
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <p>Hey guys!<p>
  14. <input type="button" value="push" onclick="func()"/>
  15. <script>
  16. func();
  17. </script>
  18. <p>Hey girls!<p>
  19. </body>
  20. </html>
  21.  
  22. document.body.insertBefore( elem, document.getElementsByTagName('p')[1] );
  23.  
  24. function func() {
  25. var elem = document.createElement("input");
  26. elem.setAttribute('type','text');
  27. var ps = document.getElementsByTagName("p");
  28. if (ps.length < 2)
  29. return; // abort! we didn't find our element
  30. var p = ps[1];
  31. document.body.insertBefore(elem, p);
  32. }
Add Comment
Please, Sign In to add comment