On Github josemalive / jQueryReference
Created by Josema Estrade
La comunicación entre un servidor web y el cliente es mas sencilla de lo que parece.
Cuando el html es recibido por el navegador, se genera el DOM
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>Ó
<script src="Lib/js/jquery-1.11.1.min.js"></script>
<script> $(document).ready(function(){ //Hacemos lo que queramos asegurandonos que la //jerarquia DOM esta cargada. }); </script> <script> window.onload => Usa pero solo carga cuando todo esta cargado (images, css...) </script>
api.jquery.com contiene toda la descripcion para cada función
disponible en jQuery
<script> $(document).ready(function(){ var imagenes = $('img'); //coleccion alert(imagenes.lenght); //shows 2 }); </script> <div> <img src="...."/> <img src="...."/> </div>
<script> $(document).ready( var paragraphs = $('p'); //coleccion paragraphs.each(function(paragraph){ alert($(this).html()); //muestra el html que hay dentro de cada p }); //podemos hacer selecciones multiples como var everything= $('div, p'); ); </script> <div> <p src="...."/> <p src="...."/> </div>
<script> $(document).ready(function(){ //"#" tendremos el elemento que coincide con el ID var imagen = $('#miImagen'); //mostraria el atributo src de la imagen alert(imagen.attr("src")); }); </script> <div> <img id="miImagen" src="...."/> <img src="...."/> </div>
<script> $(document).ready(function(){ //"#" tendremos el elemento que coincide con el ID var imagen = $('.miImagen'); //mostraria el atributo src de la imagen alert(imagen.attr("src")); //es posible seleccionar multiples cosas var imagenes = $('.miImagen, .miImagen2'); }); </script> <div> <img class="miImagen" src="...."/> <img class="miImagen2" src="...."/> </div>
<script> $(document).ready(function(){ //selecciona los 2 elementos que contienen el atributo title $('a[title]'); //selecciona solo el elemento con el atributo title = "Hola" $('a[title="Hola"]'); }); </script> <div> <a title="Hola">Link</a> <a title="Hola2">Link2</a> <a>Link3</a> <a>Link4</a> </div>
<script> $(document).ready(function(){ //selecciona todos los inputs, textbox, checkbox, radio, etc... $(':input'); //solo los radio $(':input[type="radio"]'); //obtener los radios que estan checkeados }); </script> <div> <input type="text" title="Ejemplo"/> <input type="radio"/> </div>
<script> $(document).ready(function(){ //seleccion multiple de elemento que tenga atributo id, y cuyo atributo name acabe en 'web' $("span[id][name$='web']"); }); </script> <div> <span class="algo" name="spaweb"> Ejemplo de span </span> <span class="algo" name="spa"> Ejemplo de span </span> <span class="algo" name="web"> Ejemplo de span </span> </div>
<script> $(document).ready( //seleccion multiple de elemento que tenga atributo id, y cuyo atributo name comience en 'web' $("span[id][name^='web']"); </script> <div> <span class="algo" name="spaweb"> Ejemplo de span </span> <span class="algo" name="spa"> Ejemplo de span </span> <span class="algo" name="web"> Ejemplo de span </span> </div>
<script> $(document).ready( //seleccion multiple de elemento que tenga atributo id, y cuyo atributo name contenga en 'web' $("span[id][name*='web']"); </script> <div> <span class="algo" name="spaweb"> Ejemplo de span </span> <span class="algo" name="spa"> Ejemplo de span </span> <span class="algo" name="web"> Ejemplo de span </span> </div>
<script> $(document).ready( //seleccion elemento cuyo texto contiene Ejemplo $('span:contains("Ejemplo")'); </script> <div> <span class="algo" name="spaweb">Ejemplo</span> <span class="algo" name="spa">span </span> <span class="algo" name="web">Ejemplo de span </span> </div>
<script> $(document).ready( $('span:odd'); //elementos impares $('span:even'); //elementos pares </script> <div> <span class="algo" name="spaweb">Ejemplo</span> <span class="algo" name="spa">span </span> <span class="algo" name="web">Ejemplo de span </span> </div>
<script> $(document).ready( //primer span dentro del div $('#capa:first-child'); </script> <div id="capa"> <span class="algo" name="spaweb">Ejemplo</span> <span class="algo" name="spa">span </span> <span class="algo" name="web">Ejemplo de span </span> </div>
<script> $(document).ready(function(){ //Seleccion de todos los imput checked $(':input[type="radio"]:checked'); }); </script> <div id="capa"> <input type="radio"/> <input type="checkbox" checked/> </div>
<script> $(document).ready(function(){ //Selecciona todo (devuelve un array de items) $('*'); }); </script> <div id="capa"> <input type="radio"/> <input type="checkbox" checked/> </div>
<script> $(document).ready(function(){ animarCapa(); }); function animarCapa(){ $( "#capa" ).slideToggle( "slow", animarCapa); } $('#id').click(function(){ //Seleccionaria los divs que en estos momentos estan siendo animados $('div:animated').css("background-color", "#ff0000"); }); </script> <div id="capa"> <input type="checkbox" checked/> </div> <input type="radio"/>
<script> $(document).ready(function(){ //all first childs from ul ONLY! li's with Bye will not be included $(".lista > li"); }); </script> <div id="capa"> <ul class="lista"> <li>Hello</li> <li>Hello2</li> <li>Hello3</li> <li>Hello4</li> <li> <ul> <li>Bye1</li> <li>Bye2</li> <li>Bye3</li> <li>Bye4</li> <li>Bye5</li> </ul> </li> <li>Hello6</li> <li>Hello7</li> </ul> <input type="checkbox" checked/> </div> <input type="radio"/>
<script> $(document).ready(function(){ //all divs that have no children $("div:empty"); }); </script> <div id="capa"> <ul class="lista"> <li>Hello</li> <li>Hello2</li> <li>Hello3</li> <li>Hello4</li> <li>Hello6</li> <li>Hello7</li> </ul> <input type="checkbox" checked/> </div> <div id="capa"></div> <div id="capa"></div>
<script> $(document).ready(function(){ //all elements with class "input" that has focus now. $('.input:focus'); }); </script> <div id="capa"> <ul class="lista"> <li>Hello</li> </ul> <input type="checkbox" checked/> </div> <div id="capa"></div> <div id="capa"></div>
<div id="capa"> <input type="radio"/> <input type="checkbox" checked/> </div>
You can select from different transitions, like: Cube - Page - Concave - Zoom - Linear - Fade - None - Default
Reveal.js comes with a few themes built in: Default - Sky - Beige - Simple - Serif - Night Moon - Solarized
* Theme demos are loaded after the presentation which leads to flicker. In production you should load your theme in the <head> using a <link>.
Set data-state="something" on a slide and "something" will be added as a class to the document element when the slide is open. This lets you apply broader style changes, like switching the background.
Additionally custom events can be triggered on a per slide basis by binding to the data-state name.
Reveal.addEventListener( 'customevent', function() { console.log( '"customevent" has fired' ); } );
Set data-background="#007777" on a slide to change the full page background to the given color. All CSS color formats are supported.
<section data-background="image.png">
<section data-background="image.png" data-background-repeat="repeat" data-background-size="100px">
Pass reveal.js the backgroundTransition: 'slide' config argument to make backgrounds slide rather than fade.
You can override background transitions per slide by using data-background-transition="slide".
These guys come in two forms, inline: “The nice thing about standards is that there are so many to choose from” and block:
“For years there has been a theory that millions of monkeys typing at random on millions of typewriters would reproduce the entire works of Shakespeare. The Internet has proven this theory to be untrue.”function linkify( selector ) { if( supports3DTransforms ) { var nodes = document.querySelectorAll( selector ); for( var i = 0, len = nodes.length; i < len; i++ ) { var node = nodes[i]; if( !node.className ) { node.className += ' roll'; } } } }
Courtesy of highlight.js.
You can link between slides internally, like this.
Hit the next arrow...
... to step through ...
any type of view fragments This slide has fragments which are also stepped through in the notes window.There's a few styles of fragments, like:
grow
shrink
roll-in
fade-out
highlight-red
highlight-green
highlight-blue
current-visible
highlight-current-blue
Presentations can be exported to PDF, below is an example that's been uploaded to SlideShare.
Press b or period on your keyboard to enter the 'paused' mode. This mode is helpful when you want to take distracting slides off the screen during a presentation.