Blog
Javascript Lesson 1 Variables and Operations on Them
I won't beat around the bush describing every variable type and operation—we don't need that. Our main goal is to grasp the basic syntax of JavaScript, then move on to learning jQuery, and from there you’ll be able to expand your JavaScript knowledge on your own. If you're more interested in studying JavaScript in-depth and don't care for working with this amazing framework, you should probably find a more comprehensive JavaScript textbook. But if you want to build sites in Drupal and learn jQuery afterward, then we're on the same path. So let's get started.
Javascript lesson 2 The if construct
In this lesson, we will explore how the if statement can be used in JavaScript. The syntax in JavaScript is quite similar to PHP (both were designed with C++ programmers in mind), so you can also read about if statements in this PHP lesson:
Javascript Lesson 3 While, For Loops
In this lesson, we will go over loops in JavaScript. As I mentioned earlier, the syntax of the PHP language is similar to JavaScript, so you can also take a look at loops in PHP:
PHP Lessons – Lesson 12 – Loops while, foreach, for
With one exception: JavaScript does not have a foreach() loop. Instead, we will use the each()
method in jQuery to iterate over elements in the future.
Javascript урок 4 Функции
In this lesson, we will look at functions in JavaScript—how to write them and what kinds of functions exist. You can read about functions in these PHP lessons; all the examples will also work in JavaScript:
PHP Lessons – Lesson 7 – PHP Functions and Functional Programming
Javascript Lesson 5 Arrays, Functions for Working with Arrays
In this lesson, we’ll explore another JavaScript data type: arrays. We’ll also look at some functions for working with strings and arrays. The rest of the functions will be covered in the following lessons. For an introduction to arrays, you can check out the materials on PHP arrays:
Javascript Lesson 6 Objects, Their Properties and Methods
This is the final JavaScript lesson necessary before starting to learn jQuery. But it's not the last JavaScript lesson I'll make, because the JavaScript language is much broader and has far more to offer than what I’ve covered in these lessons.
In this lesson, we’ll look at another JavaScript data type: objects. Objects can be compared to arrays whose elements are variables and functions. The variables inside objects are called object properties, and the functions are called methods. You can read more about objects in PHP here:
Drupal and jQuery
What is jQuery?
jQuery is a wonderful JavaScript library that allows you to create great web effects with just a few lines of code. As stated on the official jQuery website:
"jQuery is a JavaScript library whose motto is: writing JavaScript code should be fun. jQuery handles common, repetitive tasks, cleans up layouts, and keeps code short, beautiful, and understandable."
Drupal and jQuery. Lesson 1. Connecting a file with jQuery.
```html
jQuery is a very handy tool when you need to hide something, modify it, move it, insert it nicely, and disappear. Very, very convenient and very simple. Let's connect a JavaScript file. To attach files to a theme, we use the `.info` file in your theme. To include the file, add the following line to your theme's `.info` file:
scripts[] = js/custom.js
where `js/custom.js` is the path to the JavaScript file in your theme.
Drupal and jQuery. Lesson 2. Selectors, effects.
In this lesson, we will explore jQuery selectors and jQuery effects.
Selectors
Among selectors, we will most often use classes and IDs. Selectors generally correspond to CSS selectors, so if you know how to write selectors in CSS, you already know how to write them in jQuery. Here's how we select classes:
$('.class')
And here's how we select IDs:
$('#id')
Drupal and jQuery. Lesson 3. jQuery and CSS
In this video, we will explore how to work with CSS using the capabilities of jQuery.