lunes, 21 de octubre de 2013

JQuery

Function

$( ) is the shortcut of jquery( )

Syntaxis :   

  • $( "Selector Element" ).Method();
  • $( "Selector Element" ).Method( Function( ){  } );

JQuery select elements as CSS

h1 -> Element selector

.h1 { color: red}   ->  Css Class select a grouping of elements

#my_h1 { color: #3300FF; } -> Id Selector, only affects one element

Example 1

$("span.Italian").toggle();

<span class="Italian">Nel Mezzo del cammin di 
nostra vita</span> 
<span class="English">In the middle of this road 
called "our life"</span> 
  
<span class="Italian">mi ritrovai per una selva 
oscura</span>

Example 2

$("p#mytext").show();

<p id="mytext">One morning, when Gregor Samsa 
woke from troubled dreams . . . 
</p> 
<p id="mytext">he found himself transformed in 
his bed into a horrible vermin.</p> 
<p>He lay on his armour-like back, and if he 
lifted his head a little . . . </p>

Set up JQuery

$(document).ready( function() {

});

This mean when the DOM is ready and loaded, then do the function.







No hay comentarios:

Publicar un comentario