Skip to content

Instantly share code, notes, and snippets.

View carlosrojaso's full-sized avatar
🎯
Focusing

Carlos Rojas carlosrojaso

🎯
Focusing
View GitHub Profile
var foo = [];
foo.push( "a" );
foo.push( "b" );
alert( foo[ 0 ] ); // a
alert( foo[ 1 ] ); // b
alert( foo.length ); // 2
// Creating an object with the constructor:
var person1 = new Object;
person1.firstName = "John";
person1.lastName = "Doe";
alert( person1.firstName + " " + person1.lastName );
// Creating an object with the object literal syntax:
var person2 = {
@carlosrojaso
carlosrojaso / JSPlacement
Created May 14, 2014 20:56
JS Placement
<!doctype html>
<html>
<head>
<script>
// Attempting to access an element too early will have unexpected results.
var title = document.getElementById( "hello-world" );
console.log( title );
</script>
</head>
<body>
@carlosrojaso
carlosrojaso / jsAttributes
Created May 14, 2014 20:53
js Attributes
<!-- Inline code directly on HTML elements being clicked. -->
<a href="javascript:alert( 'Hello World' );">Click Me!</a>
<button onClick="alert( 'Good Bye World' );">Click Me Too!</button>
@carlosrojaso
carlosrojaso / Inline
Created May 14, 2014 20:52
JS Inline
<!-- Embed code directly on a web page using script tags. -->
<script>
alert( "Hello World!" );
</script>
<!-- Code is written in a .js file, included via the script tag src attribute. -->
<script src="/path/to/example.js"></script>
@carlosrojaso
carlosrojaso / ManipulatingHTMLElements
Created May 13, 2014 13:34
Manipulating HTML Elements
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p id="demo">My First Paragraph.</p>
<script>
document.getElementById("demo").innerHTML = "Paragraph changed.";
@carlosrojaso
carlosrojaso / JS hello
Last active August 29, 2015 14:01
JS hello
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript</h1>
<p>Click Date to display current day, date, and time.</p>
<button type="button" onclick="myFunction()">Date</button>
@carlosrojaso
carlosrojaso / CSS3 Multiple Columns
Created May 12, 2014 19:24
CSS3 Multiple Columns
!DOCTYPE html>
<html>
<head>
<style>
.newspaper
{
-webkit-column-count:3; /* Chrome, Safari, Opera */
-moz-column-count:3; /* Firefox */
column-count:3;
}
@carlosrojaso
carlosrojaso / CSS3 Animations
Created May 12, 2014 19:23
CSS3 Animations
<!DOCTYPE html>
<html>
<head>
<style>
div
{
width:100px;
height:100px;
background:red;
-webkit-animation:myfirst 5s; /* Chrome, Safari, Opera */