Wednesday, 5 July 2017

JavaScript

JavaScript


https://codepen.io/pen/


mdn Learning area


============================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
  <title>Apply JavaScript example</title>
</head>
<body>


  <button>Click me</button>

<script>

  // JavaScript goes here
  function createParagraph() {
  var para = document.createElement('p');
  para.textContent = 'You clicked the button!';
  document.body.appendChild(para);
}

var buttons = document.querySelectorAll('button');

for (var i = 0; i < buttons.length ; i++) {
  buttons[i].addEventListener('click', createParagraph);
}

</script>


</body>
</html>


=======================


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
  <title>Apply JavaScript example</title>
</head>
<body>


  <p>Update your name</p>
   <style>

   p {
  font-family: 'helvetica neue', helvetica, sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  border: 2px solid rgba(0,0,200,0.6);
  background: rgba(0,0,200,0.3);
  color: rgba(0,0,200,0.6);
  box-shadow: 1px 1px 2px rgba(0,0,200,0.4);
  border-radius: 10px;
  padding: 3px 10px;
  display: inline-block;
  cursor:pointer;
}
   </style>



<script>

  // JavaScript goes here
  var para = document.querySelector('p');

para.addEventListener('click', updateName);

function updateName() {
  var name = prompt('Enter your name:');
  para.textContent = 'Your Name ' + name;
}


</script>


</body>
</html>


=========================================

No comments:

Post a Comment