reading-notes

View on GitHub

jQuery

jQuery is a JavaScript file that you include in your web pages. It lets you find elements using CSS-style selectors and then do something with the elements using jQuery methods.

Examples of finding elements using CSS-style selectors :

DO SOMETHING WITH THE ELEMENTS USING JQUERY METHODS :

image

WHY USE JQUERY?

JQUERY selection :

Single element :when you try select unique element ,the selector returns one element, the jQuery object contains a reference to just one element node.

If you try to select element that has more than one copy ,the selector returns several elements so the jQuery object contains references to each element. The references of element are ordered as array started from zero

Edit element data using JQUERY methods :

DOM : Document Object Model

When a web page is loaded, the browser creates a Document Object Model of the page. The HTML DOM model is constructed as a tree of Objects

When you create a jQuery selection, the jQuery object holds references to the elements in the DOM - it does not create a copy of them.

when create a jQuery object the system do that :

  1. Find the matching nodes in the DOM tree
  2. Create the jQuery object
  3. Store references to the nodes in the jQuery object

Chaining :

Using jQuery you cane use more than one methods in the same line . $('li[id!="one"] ').hide().delay(500). fadeln(1400);

ready()

jQuery’s . ready() method checks that the page is ready for your code to work with.

(document) creates a jQuery object representing the page.

This method works when the page is loaded and DOM ready to use

` $(document).ready(function() { // Your script goes here 1) ; `

Getting element content :

Updating element :

Inserting new elements :

  1. Create the new elements in a jQuery object
  2. Use a method to insert the content into the page :
    • .before()
    • .after()
    • .prepend()
    • .append()

Class methods :

Setting CSS properties :

Change original value : $( 'li ').css( 'background- color' , '1272727' );

Event methods :

` $(‘li’) .on(‘click’, function() {$(this) .addClass( ‘ complete’); } ) ; **Get event type : (click, mouseover )** $( ‘ li ‘) .on( ‘ cl ick’ function(e){eventType = e. type ;});`

Reasons for Pair Programming :

pair programming is the practice of two developers sharing a single workstation to interactively tackle a coding task together.

pair programming commonly involves two roles:

Why pair program?

  1. Greater efficiency : pair programing takes slightly longer, but produces higher-quality code that doesn’t require later effort in troubleshooting and debugging

  2. Engaged collaboration In the pair program , programmers are more focused than if they were working alone. It is harder to procrastinate or get off track when someone else is relying on you to complete the work. 

  3. Learning from fellow students : The exchange of experiences between programmers increases their efficiency over time

  4. Social skills Pair programming is great for improving social skills

  5. Job interview readiness Most companies work on pair programming, so mastering this skill gives you an advantage during a job interview