Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.84 KB | None | 0 0
  1.  
  2.  
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6.     <meta charset="UTF-8">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  8.     <title>Title</title>
  9.     <script src="" ></script>
  10.     <link id="myId" href="" rel="stylesheet" />
  11.  
  12.     <style>
  13.         #d1{
  14.             background-color: lightgrey;
  15.             height:400px;
  16.             padding:25px;
  17.         }
  18.         #d2{
  19.             width: 200px;
  20.             height: 200px;
  21.             float: left;
  22.             background-color: green;
  23.         }
  24.         #d3{
  25.             width: 200px;
  26.             height: 200px;
  27.             float: left;
  28.             background-color: blue;
  29.             margin-left: 50px;
  30.         }
  31.     </style>
  32.  
  33. </head>
  34. <body>
  35. <div id="d1">
  36.  
  37.     <p>Paragraph in D1 <strong>BOLDED!</strong> </p>
  38.     <div id="d2"></div>
  39.     <div id="d3"></div>
  40.  
  41. </div>
  42. <!-- -->
  43. <span class="s">My custom span</span>
  44. <p class="p1">Paragraph with class</p>
  45.  
  46. <p id=p1 class="mc1" title=first>This is a paragraph.</p>
  47. <p id=p2 class="mc1" title=second>This is another paragraph.</p>
  48. <div id=d4 class="mc2" title=third> This is a divider tag</div>
  49.  
  50. <script>
  51.     /*
  52.     if you single click on d1 div,changs color to light blue
  53.      if you double click on d1 div,changes back to lightgrey
  54.      
  55.   */
  56.     var d1 = document.body.childNodes[1];
  57.    
  58.     var singleClick = function() {
  59.         if(d1.style.backgroundColor == "lightblue")
  60.             return;
  61.        
  62.         d1.style.backgroundColor = "lightblue" ;
  63.         alert("you've changed bg color to lightblue\ndouble click to change back"+"to original color" );
  64.     };
  65.    
  66.     var contextMenu = function () {
  67.         d1.style.backgroundColor = "lightgrey" ;
  68.        
  69.     }
  70.    
  71.     d1.onclick = singleClick;
  72.     d1.addEventListener('contextmenu',contextMenu);
  73.    
  74. </script>
  75.  
  76. </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement