Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script>
- function func()
- {
- var elem=document.createElement("input");
- document.body.appendChild(elem);
- elem.setAttribute('type','text');
- }
- </script>
- </head>
- <body>
- <p>Hey guys!<p>
- <input type="button" value="push" onclick="func()"/>
- <script>
- func();
- </script>
- <p>Hey girls!<p>
- </body>
- </html>
- document.body.insertBefore( elem, document.getElementsByTagName('p')[1] );
- function func() {
- var elem = document.createElement("input");
- elem.setAttribute('type','text');
- var ps = document.getElementsByTagName("p");
- if (ps.length < 2)
- return; // abort! we didn't find our element
- var p = ps[1];
- document.body.insertBefore(elem, p);
- }
Add Comment
Please, Sign In to add comment