Bootstrap Text/Typography

Bootstrap’s Default Settings Bootstrap’s global default font-size is 14px, with a line-height of 1.428. This is applied to the <body> element and all paragraphs (<p>). In addition, all <p> elements have a bottom margin that equals half their computed line-height (10px by default). Bootstrap vs. Browser Defaults In this chapter, we will look at some […]

JavaScript Data Types

JavaScript Data Types JavaScript variables can hold many data types: numbers, strings, objects and more: var length = 16;                               // Number var lastName = “Johnson”;                      // String var x = {firstName:”John”, lastName:”Doe”};    // Object The Concept of Data Types In programming, data types is an important concept. To be able to operate on variables, it is important to know something about the type. Without […]

JavaScript Syntax

JavaScript Values The JavaScript syntax defines two types of values: Fixed values and variable values. Fixed values are called literals. Variable values are called variables. JavaScript Literals The most important rules for writing fixed values are: Numbers are written with or without decimals: Strings are text, written within double or single quotes: JavaScript Variables In a programming language, variables are used […]

JavaScript Statements

JavaScript Programs A computer program is a list of “instructions” to be “executed” by a computer. In a programming language, these programming instructions are called statements. A JavaScript program is a list of programming statements. In HTML, JavaScript programs are executed by the web browser. JavaScript Statements JavaScript statements are composed of: Values, Operators, Expressions, […]

JavaScript Output

JavaScript Display Possibilities JavaScript can “display” data in different ways: Writing into an HTML element, using innerHTML. Writing into the HTML output using document.write(). Writing into an alert box, using window.alert(). Writing into the browser console, using console.log(). Using innerHTML To access an HTML element, JavaScript can use the document.getElementById(id) method. The id attribute defines […]

JavaScript Where To

JavaScript Functions and Events A JavaScript function is a block of JavaScript code, that can be executed when “called” for. For example, a function can be called when an event occurs, like when the user clicks a button. JavaScript inor You can place any number of scripts in an HTML document. Scripts can be placed […]

JavaScript Introduction

JavaScript Can Change HTML Content One of many JavaScript HTML methods is getElementById(). This example uses the method to “find” an HTML element (with id=”demo”) and changes the element content (innerHTML) to “Hello JavaScript”: document.getElementById(“demo”).innerHTML = “Hello JavaScript”; JavaScript Can Change HTML Attribute Values In this example JavaScript changes the value of the src (source) attribute of an […]