Beginner in JavaScript

Faizan Ahmed

< script type = "text/javascript" >
  document.getElementById("alertme").onclick = function() {

    alert("hell with you");

  }

< /script>
#circle {
  width: 500px;
  height: 500px;
  border-radius: 250px;
  background-color: rgba(167, 10, 10, 0.595);
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>JavaScrip!</title>

</head>

<body>

  <button id="alertme">Hello</button>


  <p id="para1">
    This is a test
  </p>
  <button id="alertp">Whats written</button>



  <p id="inco">this is</p>
  <button id="incomp">complete sentence</button>
  <p id="change">i hate it</p>
  <button id="changeMe">change it!</button>
  <div id="circle">
  </div>
  <button id="hide">hide circle!</button>
</body>

</html>
<link rel="stylesheet" href="Styles.css" type="text/css">

Hi , i am new to JavaScript. I was practicing some code and ironically my JavaScript function of simple alert didn't work. Please guide me in simple way. PS: Html and CSS were piece of cake compared to JavaScript.
Thanks.

Ashutosh Raj

your code is correct but u have not included the script in your code.

add your script in the head section or before closing the body

one more thing i want to point out is to place the style sheet in the header.

your working code onjsfiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related