Jump to content





Photo - - - - -

Workshop, Classes 4 and 5

Posted by damsch12, 17 February 2012 · 46 views

Sorry, i forgot to add class 4 :D, anyway classes 4 and 5 are related.

In class 4 we started with javascript, the first thing was how to include a a JS code, either coding it inside the HTML file, or outside in a .js file.
We played around with the alert, prompt and confirm dialogs, using them to show and assign values into variables (Note: the JS variables do not have a type, they can store anything), the teacher showed us how to convert a string into a number, and how to check if the string is really a number.

Then we learned about the conditional blocks and loops, there is no difference with other C based languages, after that he showed us how to create functions, the arrays and how they work, and the string handling methods.

After that the most important pice of info came, how to use the information typed into an HTML form component, and the DOM or Document Object Model, wich it was very usefull to fullyunderstand how to work with JS.

By the way, JS has a really special feature (irony), you dont get any kind of error, so, if your code has an error, and fails when it tries to execute, nothing will happen.
I have to tell you, JS is a really hard language to work with, not easy.

Class 5 :D

At this point JS became somewhat easier, we started learning to use JQuery. (www.jquery.com).
What is JQuery, it is a library that makes JS programming easier, the only thing you have to do is download the .js file from their site, and include it in your HTML files where you are going to use JS, then you are ready to use their libraries.

JQuery has a special code ( $() ), that you can use to call for HTML components, between the parentheses you can call object types, HTML tags, HTML id's, or CSS .class.
It also has a set of action for every one of them, like click, double click and more

You may be wondering what is this for, you can use it to give actions to a whole set of components. for example:
You have 3 buttons in your page, and you want them all to do something.

Then you can do: $(button).blur(function()); //Assign function to all 3 buttons on focus lost

Inside the function you can identify the different buttons and assign them different actions, or make them all do the same.
Or you can also add them the action separately by using their HTML id.

JQuery also has functions to handle text, attributes, changes CSS classes and more. JQuery helps you code actions in an easier and faster way than JS does.

Now we are going to have a 1 week break (yeah, vacations!! :D ), so i wont post again until the other week.




That is a lot of stuff! When you said it is like other C based languages, I lighted up :D but then you said it's hard to learn... :(

I'm not even sure I can fit in learning JS in my schedule :(
  • Report
Its not hard to learn, its hard to work with it, since it doesnt tell you anything when there is an error, thats why you need Firebug, or something similar.
  • Report

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry


This blog entry has been visited by 3 user(s)

  • Rules
  • Privacy Policy
  • Mark Community Read
  • Help