web_development:js:js-basics

Javascript basics

Test your JS: http://jsbin.com

https://stackoverflow.com/questions/407048/accessing-variables-from-other-functions-without-using-global-variables

Setting up variables:
Declaring - set the name.
Assigning - set the value.

Statements - Executable line of code. Eg. var www = $('.selector').attr(“src”, “https://example.com”);
Expression - Produces a value or is a value. Parts of larger statements. Eg. The function in this statement. $('.selector').on( 'click', function () {});
Keywords - A set of words with reserved functionality in JS. Eg. var, function, etc.
Index - The position or order of a value in an Array.

JS DOM

DOM traversal - moving from a node to its parent, children, or siblings nodes.

Traversing Upwards (parent):
.parentNode
.parentElement

Traversing to children:
1.) Any Node type: ( .childNodes, .firstChild, .lastChild )
2.) Element Nodes: ( .children, .firstElementChild, .lastElementChild, .childElementCount )

https://codepen.io/jimboobrien/pen/BJaaNz

Traversing to Siblings:
1.) Any Node type: (.nextSibling, .previousSibling )
2.) Element Nodes: (.nextElementSibling, .previousElementSibling )

  • web_development/js/js-basics.txt
  • Last modified: 2020/09/18 01:50
  • by jimboobrien