Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. //this is the javascript
  2.  
  3. function stopDesc(){
  4. var divElement = document.createElement("Div");
  5. divElement.id = "divID";
  6.  
  7. // Styling it
  8. divElement.style.textAlign = "center";
  9. divElement.style.fontWeight = "bold";
  10. divElement.style.fontSize = "smaller";
  11. //divElement.style.marginTop = "100px";
  12. divElement.style.paddingTop = "100px";
  13. divElement.style.width = "500px";
  14. divElement.style.height = "250px";
  15. divElement.style.background = "orange";
  16. divElement.style.margin="0 auto";
  17. divElement.style.color = "white";
  18. divElement.style.position="relative";
  19. divElement.style.zIndex="1000";
  20.  
  21. // Adding a paragraph
  22. var paragraph = document.createElement("P");
  23. var text =
  24. document.createTextNode("Text..................................");
  25. paragraph.appendChild(text);
  26. divElement.appendChild(paragraph);
  27.  
  28. // Adding a button
  29. var button = document.createElement("Button");
  30. var textForButton = document.createTextNode("Next->");
  31. button.appendChild(textForButton);
  32. button.addEventListener("click", function(){
  33. alert("Hi!");
  34. });
  35. divElement.appendChild(button);
  36.  
  37. // Appending the div element to body
  38. document.getElementsByTagName("body")[0].appendChild(divElement);
  39. //document.getElementById("divID").setAttribute('align','center');
  40. }
  41.  
  42. divElement.style.marginTop = "50px";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement