From the course: JavaScript: Events

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Starting to drag

Starting to drag - JavaScript Tutorial

From the course: JavaScript: Events

Start my 1-month free trial

Starting to drag

Its time to start working on the JavaScript and I am going to go ahead and delete this extra space for here from the body and just save this. We don't really need to do anything else with the Index HTML document and we're done also with the style.css. The only thing we need to work with is the script.js file, now what I'm going to do is put my functions into a self executing variable, this is called namespacing. And its a pattern popularized by Yahoo and essentially it works like this. You create a new variable. I'm going to call mine dragndrop and we set that to a function inside some parenthesis. (BLANK_AUDIO) And after that we add another parenthesis and a semicolon. And then we're going to put all of our code right here in inside this variable. The reason I'm going to do this is because I'm going to be using a couple of global variables. And this technique is going to protect any other script I might have in my HTML document from having an issue with any of my global variables…

Contents