29.07.2016 Views

front-end-developer_1_

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Front-End-Developer - Level 1<br />

$(document).ready(function() {<br />

$("#blanks form").submit(function(event) {<br />

var person1Input = $("input#person1").val();<br />

var person2Input = $("input#person2").val();<br />

var animalInput= $("input#animal").val();<br />

var exclamationInput = $("input#exclamation").val();<br />

var verbInput = $("input#verb").val();<br />

var nounInput = $("input#noun").val();<br />

$(".person1").text(person1Input);<br />

$(".person2").text(person2Input);<br />

$(".animal").text(animalInput);<br />

$(".exclamation").text(exclamationInput);<br />

$(".verb").text(verbInput);<br />

$(".noun").text(nounInput);<br />

$("#story").show();<br />

});<br />

});<br />

event.preventDefault();<br />

NEW STUFF STARTS HERE<br />

Before we move on, I want to introduce you to the idea of variable scope. A variable is only<br />

available within the function in which it was defined. Here's an example:<br />

variable-scope-example.html<br />

<br />

<br />

<br />

<br />

<br />

An adventure in variable scope<br />

<br />

<br />

click me first<br />

click me second<br />

<br />

<br />

scripts.js<br />

Forms<br />

182

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!