Day 15

This code is from a class I am taking from Stefan.  Today we covered  Event handling.
#CodingPhase #TheCodingWay #365CodingPhaseChallenge

**********

<!DOCTYPE html>
<html onkeypress="sniffer('You pressed a key!')">
<head>
<meta charset="UTF-8">
<title>Ch2 JavaScript</title>
<!--
http://www.w3schools.com/jsref/dom_obj_event.asp

Common event handlers:
- onclick
- onmouseover
- onmouseout
- onload
- onkeypress
- onchange - for form fields
-->
<script>
function sniffer(message)
{
console.log("Something happened: " + message);
}
</script>

<style type="text/css">
#secondP {width: 200px; background-color: #AFE6A5; float: right}
p:hover, button:hover {cursor: pointer;}
</style>
</head>

<body>
<h1>Welcome Uber Nerdling!</h1>

<input type="text" onchange="alert('It changed!')">

<button id="butt" type="button">Try it</button>

<p id="firstP">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>

<p id="secondP">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>

<script>
document.getElementById("butt").onmouseover=function()
{
sniffer("Inner sniffer");
}

document.getElementById("secondP").onmouseover=function()
{
alert(' Mouse over inner P ');
console.log("Log the annonymous inner function on secondP");
}

document.getElementById("firstP").onclick=function()
{
alert(' Mouse over inner 1st P ');
console.log("Log the annonymous inner function on firstP");
}
</script>
</body>
</html>

Comments

Popular posts from this blog

Day 1

Day 365 + 1

Day 365 + 2