<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cuadernodeapuntes.es &#187; JQuery</title>
	<atom:link href="http://www.cuadernodeapuntes.es/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cuadernodeapuntes.es</link>
	<description>Apuntes de informática</description>
	<lastBuildDate>Wed, 23 Jun 2010 17:58:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ajax con JQuery</title>
		<link>http://www.cuadernodeapuntes.es/2010/01/ajax-con-jquery/</link>
		<comments>http://www.cuadernodeapuntes.es/2010/01/ajax-con-jquery/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 17:46:07 +0000</pubDate>
		<dc:creator>Jrt_1990</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Memorias]]></category>
		<category><![CDATA[Sinpastaenelbolsillo.com]]></category>
		<category><![CDATA[TEWC]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.cuadernodeapuntes.es/?p=214</guid>
		<description><![CDATA[
			
				
			
		
Después de la "resaca" de la nochevieja, y de felicitar el 2010 (o 1948), es hora de ponerse las pilas y empezar con algo serio.
Esta vez voy a contar como utilizar JQuery para implementar AJAX en tu página web, y de qué manera puedes solventar el mayor problema que tiene AJAX ahora mismo, que no ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2010%2F01%2Fajax-con-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2010%2F01%2Fajax-con-jquery%2F&amp;source=capuntes&amp;style=normal&amp;service=TinyURL.com" height="61" width="50" /><br />
			</a>
		</div>
<p>Después de la "resaca" de la nochevieja, y de <a href="http://www.cuadernodeapuntes.es/2009/12/feliz-ano-a-todos-los-lectores/">felicitar el 2010</a> (o <a href="http://generacionnegativa.blogspot.com/2007/01/feliz-1984.html">1948</a>), es hora de ponerse las pilas y empezar con algo serio.<br />
Esta vez voy a contar como utilizar JQuery para implementar AJAX en tu página web, y de qué manera puedes solventar el mayor problema que tiene AJAX ahora mismo, que no es otro que la indexacion por parte de los buscadores como Google.</p>
<p>Antes de empezar voy a realizar una breve introducción a AJAX,y a comentar las ventajas y desventajas que trae, y para empezar, tengo que decir que AJAX, siglas de <em><strong>A</strong>synchronous <strong>J</strong>avaScript <strong>A</strong>nd <strong>X</strong>ML</em>, es un conjunto de 4 tecnologías que sirve para comunicar el navegador con el servidor sin necesidad de recargar la página.<br />
Esto nos brinda muchas oportunidades, ya que, junto con los efectos de JQuery se pueden lograr cosas sorprendentes, y además, como no hace falta recargar la página, podemos ahorrar ancho de banda, lo que reduce la carga del servidor.</p>
<p>No voy a entrar más en detalle, para más información puedes acceder a la <a href="http://es.wikipedia.org/wiki/AJAX">Wikipedia</a>, o buscar en Google, pero ahora vamos a implementarlo.</p>
<h2><span id="more-214"></span>Funciones AJAX de JQuery</h2>
<p>JQuery ya viene con <a href="http://docs.jquery.com/Ajax">AJAX </a>de serie, y tiene multitud de funciones muy simples que se encargan de realizar toda la labor "chunga", pero de momento con la función <a href="http://docs.jquery.com/Ajax/load">load()</a>, de momento , nos vale.</p>
<p>El funcionamiento es muy sencillo, aunque se puede complicar más para realizar peticiones mas complejas, no es necesario, y para ellas recurriremos a la función <a href="http://docs.jquery.com/Ajax/jQuery.ajax">ajax()</a>.</p>
<h3>Load()</h3>
<p>Espero que no te importe estimado navegante, que para explicar la función utilice el código de mi <a href="http://www.sinpastaenelbolsillo.com/empresas/1.html">web para ganar dinero</a>, ya que es un código que de momento funciona, y puedes ver en cualquier momento.</p>
<p>La solución al problema de los buscadores es "sencilla" pero laboriosa, ya que se trata de realizar la página sin AJAX y de manera que funcione, y después introducir el atributo <em>rel</em> en donde pondremos la url que queramos llamar para cargar, de manera que los navegadores que no tienen Javascript (como los rastreadores de Google) puedan navegar por la página, y así también, si alguien abre algún enlace en una pestaña nueva, se cargará correctamente.</p>
<p>Para la función <em>load()</em> voy a usar de ejemplo el calendario que hay en Sinpasta, ya que funciona tanto por AJAX como sin el, y su funcionamiento es muy sencillo.<br />
Antes de poner el código HTML, tengo que decir que hay un fichero, llamado <em>ajax.php</em> que simplemente recibe por parámetro una url de un archivo, y lo incluye, lo uso para evitar tener líos con las rutas relativas, y que es el que se encarga de llamar a <em>calendar.php</em>, que es el que genera toda la vista HTML del calendario.</p>
<p>El código HTML de los enlaces que hacen que el calendario cambie la vista del mes es el siguiente:</p>
<div class="igBar"><span id="lhtml-4"><a href="#" onclick="javascript:showPlainTxt('html-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-4">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ddbb00;">&amp;lt;</span>a title=&quot;Diciembre&quot; href=&quot;/index.php?fecha=2009-12&quot; rel=&quot;ajax.php?var=includes/sidebar/calendar.php<span style="color: #ddbb00;">&amp;amp;</span>amp;fecha=2009-12&quot;<span style="color: #ddbb00;">&amp;gt;</span>« Diciembre<span style="color: #ddbb00;">&amp;lt;</span>/a<span style="color: #ddbb00;">&amp;gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como puedes observar, el atributo <em>href</em> hace referencia a un archivo distinto que el atributo <em>rel</em>, a continuación pongo el Javascript necesario para que funcione con AJAX</p>
<div class="igBar"><span id="ljavascript-5"><a href="#" onclick="javascript:showPlainTxt('javascript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-5">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#prev a"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">livequery</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#calendario .sidebarcontent"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">rel</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Acabo de caer en que no he explicado livequery, y es un plugin realmente importante, así que voy a explicarlo ahora, de momento, del código anterior sólamente fijate en las líneas que hay dentro de <em>function</em>.<br />
En la primera puedes ver el funcionamiento de <em>load</em>, que lo único que hace es pedir al servidor el fichero que se encuentra donde especifica el atributo rel del elemento que lo ha llamado, y lo mete dentro de <strong>"#calendario .sidebarcontent"</strong>.<br />
En la segunda se devuelve <strong>false</strong>, de este modo el navegador no se dirigirá hacia donde apunta el atributo <em>href</em>.</p>
<h3>Pequeña pausa para explicar LiveQuery</h3>
<p>Si estás realizando una página web con AJAX, puede que te aya surgido el problema de que cargas una parte de la página con AJAX, y que de repente todos las acciones que tendrían que realizarse a través de JavaScript dentro de la parte que has cargado por AJAX no funcionan, eso es debido a que el JavaScript se aplica sobre la página una vez cargada, y al cargar nuevos elementos, no se les aplica el tratamiento JavaScript y por lo tanto no funciona.<br />
Para solucionarlo tenemos el plugin <a href="http://plugins.jquery.com/project/livequery/">LiveQuery</a>. Se instala igual que todos, y su funcionamiento es muy simple, tan sólo tienes que llamar a la función <em>livequery</em> que toma dos atributos, el primero el el "disparador", en el ejemplo anterior, era <em>click</em>, que es como si se hubiera puesto <strong>.click(function(){</strong>, pero eso no hubiera funcionado bien. El segundo atributo es la función que se va a realizar.</p>
<h3>ajax()</h3>
<p>Una vez vista la función <em>load</em>, vamos a ver como enviar un formulario a través de AJAX, ahora con la función <em>ajax()</em>, valga la redundancia.<br />
El código HTML es el que uso en <a href="http://www.sinpastaenelbolsillo.com/empresas/1.html">Sinpasta</a>, no lo voy a poner porque es muy largo y es un formulario normal, sólo que cada input tiene una <em>id</em> para acceder a él a través de los selectores de JQuery.</p>
<p>El código Javascript es el siguiente:</p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-6">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#comentario_button"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">livequery</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> noticia = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#noticia"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"value"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> autor = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#autor"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"value"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> correo = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#correo"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"value"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> url = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#url"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"value"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> comentario = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#comentario"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"value"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> dataString = <span style="color: #3366CC;">'autor='</span>+ autor + <span style="color: #3366CC;">'&amp;amp;correo='</span> + correo + <span style="color: #3366CC;">'&amp;amp;url='</span> + url + <span style="color: #3366CC;">'&amp;amp;comentario='</span> + comentario + <span style="color: #3366CC;">'&amp;amp;noticia='</span> + noticia;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#comentarios'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#comentarios'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#formulario'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#formulario'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$.<span style="color: #006600;">ajax</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">type: <span style="color: #3366CC;">"POST"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">url: <span style="color: #3366CC;">"/ajax.php?var=includes/content/formulario.php&amp;amp;noticia="</span> + noticia,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">data: dataString,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">dataType: <span style="color: #3366CC;">"html"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">success: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>respuesta<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#formulario'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span>respuesta<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#comentarios'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"/ajax.php?var=includes/content/comentarios.php&amp;amp;noticia="</span> + noticia, <span style="color: #003366; font-weight: bold;">null</span>, <span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#formulario'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"1500"</span>, <span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#comentarios'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"1500"</span>, <span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como puedes observar, he usado livequery, ya que el formulario va dentro de una parte de la página que se carga con AJAX, lo siguiente es meter en variables los campos que rellena el navegante.<br />
Después genero una String que será la que se pase en forma de petición POST al servidor, con la funcion <em>ajax()</em>, pero antes elimino todo el html que tiene el <strong>#formulario</strong> y <strong>#comentarios</strong> y los oculto.<br />
Lo que voy a comentar ahora linea a linea es lo que hay dentro de la funcion <em>ajax()</em>, que es lo más interesante:</p>
<ol>
<li>Lo primero que hago es definir el tipo de petición que es, en este caso, al enviar el formulario, prefiero que sea POST.</li>
<li>La url a donde ha de ir la petición, como siempre, a través de ajax.php.</li>
<li><strong>data</strong> hace referencia a los datos que hay que pasar, en este caso la url pasada antes.</li>
<li>El <strong>datatype</strong> indica que los datos van en HTML.</li>
<li>En esta línea indico la función que quiero que se realize, pasando como parámetro la respuesta a la petición POST.</li>
<li>Cargo el HTML de la respuesta en <strong>#formulario</strong> y en <strong>#comentarios</strong> cargo todos los comentarios de esa entrada.</li>
<li>Para acabar hago que tanto <strong>#formulario</strong> como<strong> #comentarios</strong> aparezcan con un efecto <em>fadeIn()</em>.</li>
</ol>
<p>He quitado las comprobaciones del formulario, que el correo sea válido, que todos los campos esten completados etc... para que no sea muy largo el código.</p>
<p>Existen otras muchas funciones para utilizar AJAX con JQuery, entre ellas una de las que más uso yo es getJSON, pero es un poco más avanzada, y al menos para lo básico de AJAX con lo puesto aquí es suficiente. Si te interesa el tema del JSON espero poder publicar en breves una entrada hablando sólo de él, te invito a pasarte de vez en cuando, o a suscribirte al <a href="http://feeds.feedburner.com/Cuadernodeapuntes">feed</a> para estar al tanto de su publicación.</p>
<p>Espero que te haya gustado, y sobretodo que te haya sido útil y te haya dado ideas para mejorar tu web. Siento no haber puesto fotos, se que hacen la entrada mas amena, pero en este caso no creo que fuera necesario.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1699px; width: 1px; height: 1px;">$("#comentario_button").livequery('click', function() {<br />
var noticia = $("#noticia").attr("value");<br />
var autor = $("#autor").attr("value");<br />
var correo = $("#correo").attr("value");<br />
var url = $("#url").attr("value");<br />
var comentario = $("#comentario").attr("value");</p>
<p>if (autor == "") {<br />
$("#autor_error").show();<br />
$("#autor").focus();<br />
return false;<br />
}</p>
<p>if (correo == "") {<br />
$("#correo_error").show();<br />
$("#correo").focus();<br />
return false;<br />
}</p>
<p>if (comentario == "") {<br />
$("#comentario_error").show();<br />
$("#comentario").focus();<br />
return false;<br />
}</p>
<p>var dataString = 'autor='+ autor + '&amp;correo=' + correo + '&amp;url=' + url + '&amp;comentario=' + comentario + '&amp;noticia=' + noticia;</p>
<p>$('#comentarios').empty();<br />
$('#comentarios').hide();<br />
$('#formulario').empty();<br />
$('#formulario').hide();</p>
<p>$.ajax({<br />
type: "POST",<br />
url: "/ajax.php?var=includes/content/formulario.php&amp;noticia=" + noticia,<br />
data: dataString,<br />
dataType: "html",<br />
success: function(respuesta) {<br />
$('#formulario').html(respuesta);<br />
$('#comentarios').load("/ajax.php?var=includes/content/comentarios.php&amp;noticia=" + noticia, null, null);<br />
$('#formulario').fadeIn("1500", null);<br />
$('#comentarios').fadeIn("1500", null);<br />
}<br />
});</p>
<p>return false;<br />
});</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.cuadernodeapuntes.es/2010/01/ajax-con-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Menú animado con Lavalavamp</title>
		<link>http://www.cuadernodeapuntes.es/2009/12/menu-animado-con-lavalavamp/</link>
		<comments>http://www.cuadernodeapuntes.es/2009/12/menu-animado-con-lavalavamp/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 13:21:47 +0000</pubDate>
		<dc:creator>Jrt_1990</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Memorias]]></category>
		<category><![CDATA[TEWC]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[Sinpastaenelbolsillo.com]]></category>

		<guid isPermaLink="false">http://www.cuadernodeapuntes.es/?p=163</guid>
		<description><![CDATA[
			
				
			
		
Llevo un tiempo alejado del blog por motivos navideños, pero bueno, hoy te traigo un tutorial sobre cómo personalizar un menú animado usando el plugin Lavalamp.

Conociendo lavalamp:
Lavalamp es un plugin para realizar menús mas llamativos para tu web.
Viene con tres ejemplos, que son los siguientes:
Con imagen:

Home
Plant a tree
Travel
Ride an elephant

Sin imagen

Home
Plant a tree
Travel
Ride an elephant

Subrayado

Home
Plant ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2009%2F12%2Fmenu-animado-con-lavalavamp%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2009%2F12%2Fmenu-animado-con-lavalavamp%2F&amp;source=capuntes&amp;style=normal&amp;service=TinyURL.com" height="61" width="50" /><br />
			</a>
		</div>
<p>Llevo un tiempo alejado del blog por motivos navideños, pero bueno, hoy te traigo un tutorial sobre cómo personalizar un menú animado usando el plugin <a href="http://plugins.jquery.com/project/lavalamp2">Lavalamp</a>.</p>
<p><span id="more-163"></span></p>
<h2>Conociendo lavalamp:</h2>
<p>Lavalamp es un plugin para realizar menús mas llamativos para tu web.<br />
Viene con tres ejemplos, que son los siguientes:</p>
<h3>Con imagen:</h3>
<ul id="1" class="lavaLampWithImage">
<li><a href="#">Home</a></li>
<li><a href="#">Plant a tree</a></li>
<li><a href="#">Travel</a></li>
<li><a href="#">Ride an elephant</a></li>
</ul>
<h3>Sin imagen</h3>
<ul id="2" class="lavaLampNoImage">
<li><a href="#">Home</a></li>
<li><a href="#">Plant a tree</a></li>
<li><a href="#">Travel</a></li>
<li><a href="#">Ride an elephant</a></li>
</ul>
<h3>Subrayado</h3>
<ul id="3" class="lavaLampBottomStyle">
<li><a href="#">Home</a></li>
<li><a href="#">Plant a tree</a></li>
<li><a href="#">Travel</a></li>
<li><a href="#">Ride an elephant</a></li>
</ul>
<p>Nosotros nos vamos a fijar en el primero, el de la imagen, que es el que utilizaremos para editar.</p>
<h2>Preparando el HTML</h2>
<p>Si te fijas en el menú que hay en <a href="http://www.sinpastaenelbolsillo.com/">mi web para ganar dinero</a>, entre cada elemento del menú hay un separador, y al pasar el selector por el, desaparece como pasando por debajo, a parte de tener el primer elemento y el último redondeados.<br />
Voy a explicar cómo lo hice, pero primero pongo el código HTML y lo comento:</p>
<div class="igBar"><span id="lhtml-20"><a href="#" onclick="javascript:showPlainTxt('html-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-20">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"menu"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">&lt;ul</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"l"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"first"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">&lt;ul</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"central"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"current"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"/"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Home<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://blog.sinpastaenelbolsillo.com"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Blog<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://foro.sinpastaenelbolsillo.com"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Foro<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://www.sinpastaenelbolsillo.com/faqs.php"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>F.A.Q's<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"http://www.sinpastaenelbolsillo.com/contact_us.php"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>Contacto<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">&lt;ul&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"last"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Comento por lineas, que es mejor:</p>
<ol>
<li>Esto simplemente es el <strong>div</strong> que engloba todo el menú.</li>
<li>Este primer <strong>ul</strong> es para el lateral izquierdo redondeado, por eso su...</li>
<li>...único <strong>li</strong> no tiene texto, solo <em>&amp;nbsp;</em>, que es un espacio en blanco...</li>
<li>...y cierre del <strong>ul</strong>.</li>
<li>Aquí está la "chicha" del menú, como puedes observar, después de abrir el <strong>ul</strong>...</li>
<li>...lo primero que hay es un <strong>li</strong> con clase <em>spacer</em>, que no es mas que un separador.</li>
<li>Este elemento tiene la clase <em>current</em> que quiere decir que es el elemento sobre el que "descansa" la sombra.</li>
<li>Otro <em>spacer</em>.</li>
<li>Enlace hacia el blog.</li>
<li><em>Spacer</em>.</li>
<li>Enlace hacia el foro.</li>
<li><em>Spacer</em>.</li>
<li>Enlace a preguntas frecuentes.</li>
<li><em>Spacer</em>.</li>
<li>Último elemento con enlace hacia Contacto.</li>
<li><em>Spacer</em>.</li>
<li>Cierre del <strong>ul</strong>.</li>
<li>De aquí en adelante un <strong>ul</strong> para hacer el  lateral derecho al igual que el izquierdo, y cierre del <strong>div</strong>.</li>
</ol>
<p>Ahora que ya tenemos el html, vamos con el CSS...</p>
<h2>Dando un poco de estilo con CSS</h2>
<p>Como son bastantes selectores, voy a ir comentandolos de uno en uno</p>
<h3>El primer elemento es el que hace referencia al menú entero, el <strong>div</strong> con <em>menu</em> como id</h3>
<div class="igBar"><span id="lcss-21"><a href="#" onclick="javascript:showPlainTxt('css-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-21">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#menu <span style="color: #66cc66;">&#123;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">width</span>: 940px;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span>: 55px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<ol>
<li>Selector.</li>
<li>Un ancho excesivo, pero así me aseguro que no se caerá ningún elemento.</li>
<li>La altura.</li>
<li>Al principio no se muestra, pero se mostrará con JQuery poniéndole un efecto.</li>
<li>Margen a 0.</li>
</ol>
<h3>El primer <strong>ul</strong> del menú</h3>
<div class="igBar"><span id="lcss-22"><a href="#" onclick="javascript:showPlainTxt('css-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-22">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #6666ff;">.l </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">float</span>: <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Simplemente se alinea a la izquierda.</p>
<h3>Ahora el elemento <em>central</em> del menú</h3>
<div class="igBar"><span id="lcss-23"><a href="#" onclick="javascript:showPlainTxt('css-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-23">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu <span style="color: #6666ff;">.central </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">position</span>: <span style="color: #993333;">relative</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">overflow</span>: <span style="color: #993333;">hidden</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">float</span>: <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<ol>
<li>Selector.</li>
<li>El <strong>position</strong> <em>relative</em> es necesario para que no haga cosas extrañas la "sombra".</li>
<li>La propiedad <strong>overflow</strong> con el valor <em>hidden</em> hace que cuando algo se vaya a mostrar fuera de su espacio reservado, lo que se escapa no se muestre.</li>
<li>El <strong>float</strong> <em>left</em> es necesario para que no se descuelgue el último <strong>ul</strong>.</li>
</ol>
<h3>Características generales de ul y li</h3>
<p><span style="float: left"></p>
<div class="igBar"><span id="lcss-24"><a href="#" onclick="javascript:showPlainTxt('css-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-24">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu ul <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">list-style</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: <span style="color: #993333;">normal</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</span><br />
<span style="float: right"></p>
<div class="igBar"><span id="lcss-25"><a href="#" onclick="javascript:showPlainTxt('css-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-25">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu li <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span>: 55px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">float</span>: <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span>images/menu.gif<span style="color: #66cc66;">&#41;</span> <span style="color: #993333;">repeat-x</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</span></p>
<div style="clear: both;">Son sencillas y como esta quedando un tutorial demasiado largo, voy a obviar su explicación.</div>
<h3>Ahora vamos a empezar a editar el CSS que afecta a la sombra de LavaLamp</h3>
<div class="igBar"><span id="lcss-26"><a href="#" onclick="javascript:showPlainTxt('css-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-26">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu li<span style="color: #6666ff;">.back </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">z-index</span>: <span style="color: #cc66cc;color:#800000;">8</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span>: 55px;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"images/menuhover.gif"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">position</span>: <span style="color: #993333;">absolute</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<ol>
<li>Selector dado por LavaLamp.</li>
<li>La propiedad <strong>z-index</strong> se utiliza para traer al frente este elemento, por encima de todos aquellos que tengan un <strong>z-index</strong> menor a <em>8</em>.</li>
<li><strong>Display</strong> <em>block</em><strong> </strong>muestra el inicio de la sombra como un elemento que forma parte del bloque.</li>
<li>La altura.</li>
<li>La imagen de fondo.</li>
<li><strong>z-index</strong> sólo se aplica a elementos posicionados, asi que toca posicionar este.</li>
<li>Le quitamos el borde.</li>
</ol>
<div class="igBar"><span id="lcss-27"><a href="#" onclick="javascript:showPlainTxt('css-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-27">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu li<span style="color: #6666ff;">.back </span><span style="color: #6666ff;">.<span style="color: #000000; font-weight: bold;">left</span> </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"images/menuhover.gif"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333;">repeat-x</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span>: 55px;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-right</span>: 0px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<ol>
<li>Selector dado por LavaLamp.</li>
<li>Ponemos la misma imagen que antes, pero ahora si que la repetimos a lo largo del eje x.</li>
<li>Mismo <strong>display</strong> que el elemento anterior.</li>
<li>Misma altura.</li>
<li>Le quitamos el margen de la izquierda.</li>
<li>Le quitamos el borde.</li>
</ol>
<h2>Vamos a por los <em>spacers</em></h2>
<div class="igBar"><span id="lcss-28"><a href="#" onclick="javascript:showPlainTxt('css-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-28">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu <span style="color: #6666ff;">.spacer </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">width</span>: 2px;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border</span>:<span style="color: #993333;">none</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'images/spacer2.gif'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333;">repeat-x</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">z-index</span>: <span style="color: #cc66cc;color:#800000;">10</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">position</span>: <span style="color: #993333;">relative</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border-right</span>: 1px <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border-left</span>: 1px <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span>: 55px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Este elemento realmente no tiene mucha explicación, solamente se ponen los bordes laterales, y un <strong>z-index</strong> de valor <em>10</em>, que hace que se muestre por encima de la "sombra" y asi parece que pasa "por debajo".<br />
La imagen de fondo no es más que una tira con sombra, que era de una variación que hice del primer diseño, ahora habría que poner algo transparente pero entonces no quedaría tan bien.</p>
<h3>Ya casi está todo, vamos con los enlaces del menú</h3>
<div class="igBar"><span id="lcss-29"><a href="#" onclick="javascript:showPlainTxt('css-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-29">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu a <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">float</span>: <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">height</span>: 25px;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin</span>: <span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 5px;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 13px 30px 5px 30px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-decoration</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #993333;">center</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, <span style="color: #993333;">sans-serif</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 14px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #FFFFFF;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">z-index</span>:<span style="color: #cc66cc;color:#800000;">10</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">position</span>:<span style="color: #993333;">relative</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Mencionar solo el atriburo <strong>padding</strong>, que hace que la zona de click sea mayor, el <strong>z-index</strong> que hace que se muestren las letras por encima de todo, la alineación centrada y el <strong>float</strong> <em>left</em>, el resto es, como gustan decir en mi escuela, trivial.</p>
<h3>Para terminar, los laterales redondeados</h3>
<p><span style="float: left"></p>
<div class="igBar"><span id="lcss-30"><a href="#" onclick="javascript:showPlainTxt('css-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-30">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu <span style="color: #6666ff;">.first </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span>images/menufirst.gif<span style="color: #66cc66;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">width</span>: 9px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</span><br />
<span style="float: right"></p>
<div class="igBar"><span id="lcss-31"><a href="#" onclick="javascript:showPlainTxt('css-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-31">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#menu <span style="color: #6666ff;">.last </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background</span>: <span style="color: #993333;">url</span><span style="color: #66cc66;">&#40;</span>images/menulast.gif<span style="color: #66cc66;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">width</span>: 9px;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #993333;">none</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></span></p>
<div style="clear: both;">Simplemente, es poner un ancho igual al de la imagen de fondo y eliminar los bordes.</div>
<h2 style="clear: both; text-align: left;">Instalando LavaLamp.</h2>
<p>Ahora viene lo más sencillo, como casi todo con <a href="http://jquery.com/">JQuery</a>.<br />
Te recomiendo, que le eches un ojo a la <a href="http://www.cuadernodeapuntes.es/2009/12/introduccion-a-jquery/">introducción a JQuery</a> de este blog, para ir más rápido todavía.</p>
<p>Lo primero que tienes que hacer es descargarte el plugin, si esque no lo has hecho ya, <a href="http://www.gmarwaha.com/jquery/lavalamp/zip/lavalamp_0.1.0.zip">comprimido en un zip</a>, o directamente en <a href="http://www.gmarwaha.com/jquery/lavalamp/js/jquery.lavalamp.js">*.js</a>, todo desde <a href="http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/">este enlace</a>, en el cual explican en inglés como funciona.</p>
<p>Ahora, tal como lo explico en la <a href="../2009/12/introduccion-a-jquery/">introducción a JQuery</a>, tienes que enlazar los ficheros <em>*.js</em> dentro del <em>head</em> de tu página.</p>
<p>Una vez echo esto, con la siguiente función, activarás el LavaLamp sobre el elemento central del menú:</p>
<div class="igBar"><span id="ljavascript-32"><a href="#" onclick="javascript:showPlainTxt('javascript-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-32">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#menu .central"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lavaLamp</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; fx: <span style="color: #3366CC;">"backout"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; speed: <span style="color: #CC0000;color:#800000;">700</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y el resultado final... puedes verlo en <a href="http://www.sinpastaenelbolsillo.com">Sinpastaenelbolsillo.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cuadernodeapuntes.es/2009/12/menu-animado-con-lavalavamp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Efecto &#8220;cortinilla&#8221; vertical con JQuery</title>
		<link>http://www.cuadernodeapuntes.es/2009/12/efecto-cortinilla-vertical-con-jquery/</link>
		<comments>http://www.cuadernodeapuntes.es/2009/12/efecto-cortinilla-vertical-con-jquery/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 10:02:39 +0000</pubDate>
		<dc:creator>Jrt_1990</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Memorias]]></category>
		<category><![CDATA[Sinpastaenelbolsillo.com]]></category>
		<category><![CDATA[TEWC]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.cuadernodeapuntes.es/?p=141</guid>
		<description><![CDATA[
			
				
			
		
He pensado que para empezar a poner ejemplos de JQuery lo mejor es empezar por algo sencillo, y lo más sencillo que tengo hecho en la página, a parte de los bordes redondeados que ya explicaré, es la posibilidad de crear un efecto de contracción y expansión de los elementos del sidebar, no preguntes la ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2009%2F12%2Fefecto-cortinilla-vertical-con-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2009%2F12%2Fefecto-cortinilla-vertical-con-jquery%2F&amp;source=capuntes&amp;style=normal&amp;service=TinyURL.com" height="61" width="50" /><br />
			</a>
		</div>
<p>He pensado que para empezar a poner ejemplos de JQuery lo mejor es empezar por algo sencillo, y lo más sencillo que tengo hecho en la página, a parte de los bordes redondeados que ya explicaré, es la posibilidad de crear un efecto de contracción y expansión de los elementos del sidebar, no preguntes la utilizad, simplemente me pareció bien implementarlo <img src='http://www.cuadernodeapuntes.es/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-141"></span></p>
<p>Si has ido siguiendo este blog, y has estructurado el sidebar como expliqué en <a href="http://www.cuadernodeapuntes.es/2009/12/memorias-de-un-webmaster-cssi/">esta entrada</a> simplemente tendrá que copiar y pegar la siguiente función en el documento <em>ready.js</em>, sino, tienes dos posibles caminos, entender el código y adaptarlo, cosa que no es muy difícil, o ir a la entrada en cuestión y estructurar tu sidebar así, lo más recomendable.</p>
<p>Primero pongo el código, y después lo explico:</p>
<div class="igBar"><span id="ljavascript-34"><a href="#" onclick="javascript:showPlainTxt('javascript-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-34">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.sidebartop'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">":hidden"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">slideDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">slideUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Parece más complejo de lo que realmente es, pero no te preocupes, traduciré por lineas:</p>
<ol>
<li>"Al hacer <strong>click</strong> en un elemento <em>.sidebartop</em>..."</li>
<li>"...si el <span title=".next()">elemento siguiente</span> a <span title="$(this)">éste (en el que he hecho click)</span> <span title=".is()">está</span> <span title="(':hidden')">oculto</span>..."</li>
<li>"...<span title=".slideDown()">desplegar hacia abajo</span> el <span title=".next()">elemento siguiente</span> a <span title="$(this)">éste</span>..."</li>
<li>"...<span title="else">en caso contrario</span>..."</li>
<li>"...<span title=".slideUp()">contraer</span> el <span title=".next()">elemento siguiente</span> a <span title="$(this)">éste</span>..."</li>
<li>Esta linea y siguientes sólo acaban de cerrar la función.</li>
</ol>
<p>Puedes dejar el ratón encima de algo que no entiendas para que aparezca un texto que te diga que parte del código es la que realiza cada cosa.</p>
<p>Como puedes observar es muy sencillo realizar un <strong>efecto "cortinilla" con JQuery</strong>.</p>
<p>Para terminar, te recomiendo echarle un ojo a las funciones <a href="http://docs.jquery.com/Effects/slideUp#speedcallback">slideUp()</a> y <a href="http://docs.jquery.com/Effects/slideDown#speedcallback">slideDown()</a>, ya que aceptan como pará metros la velocidad del efecto y funciones a realizar al terminarlo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cuadernodeapuntes.es/2009/12/efecto-cortinilla-vertical-con-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducción a JQuery</title>
		<link>http://www.cuadernodeapuntes.es/2009/12/introduccion-a-jquery/</link>
		<comments>http://www.cuadernodeapuntes.es/2009/12/introduccion-a-jquery/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 14:49:35 +0000</pubDate>
		<dc:creator>Jrt_1990</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Memorias]]></category>
		<category><![CDATA[TEWC]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.cuadernodeapuntes.es/?p=75</guid>
		<description><![CDATA[
			
				
			
		
Llevo unos días sin publicar ningún tutorial o memoria, y como hoy no tengo demasiado tiempo, he decidido publicar una introducción a JQuery, utilizada en mi web de ganar dinero para conseguir efectos como el contraer y expandir los elementos del sidebar (hacer click en el título de cada uno), tener bordes redondeados, utilizar Ajax ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2009%2F12%2Fintroduccion-a-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.cuadernodeapuntes.es%2F2009%2F12%2Fintroduccion-a-jquery%2F&amp;source=capuntes&amp;style=normal&amp;service=TinyURL.com" height="61" width="50" /><br />
			</a>
		</div>
<p>Llevo unos días sin publicar ningún tutorial o memoria, y como hoy no tengo demasiado tiempo, he decidido publicar una introducción a JQuery, utilizada en mi web de ganar dinero para conseguir efectos como el contraer y expandir los elementos del sidebar (hacer click en el título de cada uno), tener bordes redondeados, utilizar Ajax + Json para optimizar el tráfico y un sinfín más de cosas que puedes hacer de la manera mas sencilla que puedas imaginar.</p>
<p><span id="more-75"></span></p>
<h2>¿Qué es JQuery?</h2>
<p><a href="http://es.wikipedia.org/wiki/JQuery">JQuery</a> es un <a href="http://es.wikipedia.org/wiki/Framework">framework</a> de <a href="http://es.wikipedia.org/wiki/Javascript">Javascript</a>, que permite interactuar fácilmente con los elementos HTML, manipular el arbol <a href="http://es.wikipedia.org/wiki/DOM">DOM</a>, manejar eventos y animaciones e integrar la tecnología <a href="http://es.wikipedia.org/wiki/AJAX">AJAX</a> de manera fácil y cómoda.<br />
He puesto enlaces a la wikipedia en todas las palabras que considero que es recomendable conocer, y decir que la definición la he basado en la de la wikipedia.</p>
<h2>¿Cómo se instala?</h2>
<p>De la forma mas sencilla que puedas imaginarte, simplemente accede a la <a href="http://jquery.com/">página oficial de JQuery</a> y descárgatelo en la carpeta donde tengas la página web, en mi caso uso la versión 1.3.2 en su versión completa, así que tengo un fichero llamado <strong>jquery-1.3.2.js</strong>.</p>
<p>Ahora tienes que ir al fichero <strong>index.html</strong> y añadir la siguiente linea a la cabecera (dentro de las etiquetas <em>&lt;head&gt;&lt;/head&gt;</em>)</p>
<div class="igBar"><span id="lhtml-41"><a href="#" onclick="javascript:showPlainTxt('html-41'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-41">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"jquery-1.3.2.js"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y ya está listo para ser usado.</p>
<h2>¿Cómo empiezo a hacer cosas con JQuery?</h2>
<p>Este fin de semana empezaré a publicar entradas con todo lo que he hecho con JQuery en <a href="http://www.sinpastaenelbolsillo.com/empresas/1.html">Sinpastaenelbolsillo</a>, pero si no puedes esperar hasta entonces, vamos a hablar un poco de los selectores, algunas funciones básicas y de los plugins</p>
<h3>Selectores:</h3>
<p>El primer paso para poder hacer cosas con JQuery es saber como seleccionar cada elemento, y para eso está la función $(String), que devuelve el elemento (o elementos) que están definidos como se indica en la String, pongo unos ejemplos</p>
<div class="igBar"><span id="ljavascript-42"><a href="#" onclick="javascript:showPlainTxt('javascript-42'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-42">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"body"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">//Devuelve el body</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#menu"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">//Devuelve el menú</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">".sidebarcontent"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">//Devuelve los sidebarcontents</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">".post p"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">//Devuelve los párrafos dentro de post </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como puedes observar, la String que hay que pasar como parámetros, son los selectores que usas normalmente en el CSS.</p>
<h3>Funciones básicas y/o más comunes:</h3>
<p><a href="http://docs.jquery.com/Attributes/addClass#class"><strong>addClass(</strong><em>String</em></a><strong><a href="http://docs.jquery.com/Attributes/addClass#class">)</a>/<a href="http://docs.jquery.com/Attributes/removeClass#class">removeClass(</a></strong><a href="http://docs.jquery.com/Attributes/removeClass#class"><em>String</em></a><strong><a href="http://docs.jquery.com/Attributes/removeClass#class">)</a> </strong>-<strong> </strong>Estos dos métodos sirven para añadir o eliminar clases a los elementos html seleccionados, de manera que puedes cambiar el estilo de cualquier cosa de manera dinámica.</p>
<p>Ejemplo:</p>
<div class="igBar"><span id="ljavascript-43"><a href="#" onclick="javascript:showPlainTxt('javascript-43'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-43">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"body"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"fondoNegro"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lcss-44"><a href="#" onclick="javascript:showPlainTxt('css-44'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CSS:</span>
<div id="css-44">
<div class="css">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #6666ff;">.fondoNegro </span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">background-color</span>: #000000;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En el ejemplo, al ejecutarse JQuery, le añadirá la clase fondoNegro al body, y el fondo de la página será negro.</p>
<p><a href="http://docs.jquery.com/Attributes/html"><strong>html(</strong><em>String</em></a><strong><a href="http://docs.jquery.com/Attributes/html">)</a> </strong>- Con este método cambiaremos el html que haya dentro de un elemento por el pasado como String.<br />
Si no pasas ningún atributo, es decir, lo dejas en <a href="http://docs.jquery.com/Attributes/html"><strong>html()</strong></a> te devuelve el html que haya dentro del elemento seleccionado.</p>
<p>Ejemplo:</p>
<div class="igBar"><span id="ljavascript-45"><a href="#" onclick="javascript:showPlainTxt('javascript-45'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-45">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"body"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">html</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #3366CC;">&nbsp; &nbsp; &nbsp;&lt;h1&gt;Hola!!&lt;/h1&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #3366CC;">"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora, al ejecutarse, cambiará el contenido del body por "&lt;h1&gt;Hola!!&lt;/h1&gt;".</p>
<p><strong><a href="http://docs.jquery.com/Effects/show">show()</a>/<a href="http://docs.jquery.com/Effects/hide">hide()</a></strong> - Muestra/oculta los elementos seleccionados. Ambos tienen una <a href="http://docs.jquery.com/Effects">variante</a> con paŕametos que sirven para modificar la velocidad a la que muesta/oculta los elementos seleccionados.</p>
<h3>Plugins:</h3>
<p>Existen multitud de <a href="http://plugins.jquery.com/">plugins</a> para JQuery creados por la comunidad, con infinita variedad de efectos, desde menús animados, como el que tengo en mi <a href="http://www.sinpastaenelbolsillo.com/empresas/1.html">web para ganar dinero</a>, redondear elementos o widgets para añadir a tu web.</p>
<p>Instalarlos suele ser sencillo, por regla general viene un fichero README en el cual indican la instalación, que no suele ser mas complicada que extraer los ficheros dentro del servidor y enlazarlos dentro de <em>&lt;head&gt;&lt;/head&gt;</em> al igual que hiciste con JQuery.</p>
<p>Para finalizar, y en previsión de siguientes tutoriales, te recomiendo crear un documento <strong>*.js</strong> llamado <strong>ready</strong>, es decir, un fichero llamado <em>ready.js</em>, y enlazarlo como si fuera un plugin.<br />
En este documento irá todo lo que se tiene que ejecutar cuando la página esté cargada, para ello escribe lo siguiente dentro del fichero y dejalo asi:</p>
<div class="igBar"><span id="ljavascript-46"><a href="#" onclick="javascript:showPlainTxt('javascript-46'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-46">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cuadernodeapuntes.es/2009/12/introduccion-a-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
