<?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>Mas que Wordpress - Tutoriales, recursos web, JQuery y PHP, Wordpress , twitter y muchos recursos más &#187; JQuery</title>
	<atom:link href="http://www.masquewordpress.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.masquewordpress.com</link>
	<description>Tutoriales y recursos web sobre JQuery , PHP, Wordpress , twitter. Aprende diseño web y programación</description>
	<lastBuildDate>Fri, 03 Feb 2012 19:33:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Scroll con Jquery sin plugins</title>
		<link>http://www.masquewordpress.com/scroll-con-jquery-sin-plugins/</link>
		<comments>http://www.masquewordpress.com/scroll-con-jquery-sin-plugins/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 14:06:42 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[tutorial jquery]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=1103</guid>
		<description><![CDATA[Uno de los post más consultados en mi blog es el de  , que no es ni más ni menos que un plugin para animar la pantalla en lugar de usar los aburridos y anticuados anchors de HTML. Como en dicho en montón de oportunidades no siempre me gusta usar plugin para realizar tareas sencillas. [...]]]></description>
			<content:encoded><![CDATA[<p>Uno de los post más consultados en mi blog es el de <a href="http://www.masquewordpress.com/jquery-scrollto-olvidate-de-usar-anchors-aburridos/">jQuery.ScrollTo</a> , que no es ni más ni menos que un plugin para animar la pantalla en lugar de usar los aburridos y anticuados anchors de HTML. Como en dicho en montón de oportunidades no siempre me gusta usar plugin para realizar tareas sencillas.</p>
<p>En el caso de un scroll , si lo que quieren es animar la pantalla para volver a la parte superior de sus sitios webs no hay nada más sencillo para hacer que lo siguiente:</p>
<p><span id="more-1103"></span></p>
<p>Por ejemplo si en el header a nuestro logo le agregamos la clase <strong>.top-page</strong></p>
<p>En el footer podemos colocar un link, una imagen o lo que ustedes quieran como por ejemplo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;a class=&quot;top&quot; href=&quot;top-page&quot;&gt;Click para subir &lt;/a&gt;</pre></td></tr></table></div>

<p>Por último agregamos el código jQuery encargado de animar nuestro anchor.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'document'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.top'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> elementClicked <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #003366; font-weight: bold;">var</span> destination <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #339933;">+</span>elementClicked<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span><span style="color: #339933;">;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;html:not(:animated),body:not(:animated)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> scrollTop<span style="color: #339933;">:</span> destination<span style="color: #339933;">-</span><span style="color: #CC0000;">20</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<a target="_blank" href="http://www.masquewordpress.com/ejemplos/scroll-con-jquery-facil/" class="avia-button  dark xl" ><span class="avia-note">Ver Ejemplo Online</span></a>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/scroll-con-jquery-sin-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validar email con Javascript sin un plugin</title>
		<link>http://www.masquewordpress.com/validar-email-con-jquery-sin-un-plugin/</link>
		<comments>http://www.masquewordpress.com/validar-email-con-jquery-sin-un-plugin/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 14:23:28 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[tutorial jquery]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=960</guid>
		<description><![CDATA[Todos saben que no me gusta instalar cuando tan solo requiero pequeñas funciones. Por ejemplo para validar un email no creo necesario instalar un plugin que realize validación de formularios sino más bien crear una pequeña función que valide dicho email y listo. Con esta pequeña función pueden validad direcciones de email con jQuery Javascript. [...]]]></description>
			<content:encoded><![CDATA[<p>Todos saben que no me gusta instalar <a href="http://www.masquewordpress.com/240-plugins-para-jquery-lo-mejor-de-lo-mejor/">plugins de jQuery</a> cuando tan solo requiero pequeñas funciones. Por ejemplo para validar un email no creo necesario instalar un plugin que realize validación de formularios sino más bien crear una pequeña función que valide dicho email y listo.<br />
<span id="more-960"></span><br />
Con esta pequeña función pueden validad direcciones de email con <del datetime="2012-01-18T17:05:31+00:00">jQuery</del> Javascript.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> validateEmail<span style="color: #009900;">&#40;</span>$email<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> emailReg <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>emailReg.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span> $email <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Saludos!!</p>
<p><strong>Update:</strong>Como bien comenta Franz en los comentarios no hay jQuery en este artículo. Eso me pasa por escribir apurado sobre un borrador que tenía preparado que en un principio iba a usar jQuery y luego no fue así. Gracias lectores por estar atentos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/validar-email-con-jquery-sin-un-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Diferencia entre $(document).ready y $(window).load en jQuery</title>
		<link>http://www.masquewordpress.com/diferencia-entre-document-ready-y-window-load-en-jquery/</link>
		<comments>http://www.masquewordpress.com/diferencia-entre-document-ready-y-window-load-en-jquery/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 19:07:27 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[tutorial jquery]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=957</guid>
		<description><![CDATA[Hoy les voy a explicar la principal diferencia entre $(document).ready y $(window).load , funciones esenciales a la hora de usar en tus programas. 1 2 3 $&#40;document&#41;.ready&#40;function&#40;&#41;&#123; //todo el código &#125;&#41;; El código que ven más arriba se suele usar la mayoría del tiempo y en casi todos lados lo mencionan como la mejor manera de [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy les voy a explicar la principal diferencia entre <strong>$(document).ready</strong> y <strong>$(window).load </strong>, funciones esenciales a la hora de usar <a href="http://www.masquewordpress.com/category/jquery/">jQuery</a> en tus programas.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//todo el código</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>El código que ven más arriba se suele usar la mayoría del tiempo y en casi todos lados lo mencionan como la mejor manera de ejecutar nuestro código después del que el <a href="http://es.wikipedia.org/wiki/Document_Object_Model" rel="nofollow">DOM</a> esta listo.<br />
<span id="more-957"></span></p>
<h3>Entonces para que se necesita <strong>$(window).load() </strong>?</h3>
<p>Yo hasta ahora lo he utilizado para trabajar con imágenes. Cuando se necesita manipular imágenes para por ejemplo alinearlas o se necesita obtener el width y height de las mismas necesitaremos sí o sí utilizar <strong>$(window).load()</strong>.<br />
Con <strong>$(document).ready() </strong> no podrás hacer eso si el usuario no tiene cargadas las imágenes en la cache o en otras palabras tu código siempre fallaría con nuevos usuarios.</p>
<p>A diferencia de este último <strong>$(window).load()</strong> ejecutará el código una vez hayan cargado todas las imágenes. A simple vista no se observa diferencia ninguna en cuanto a tiempo, pero si alguna vez tuvieron que manipular imágenes cuando carga una página sabrán a que me refiero.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Código ejecutado después de que se carguen la imágenes.</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Saludos!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/diferencia-entre-document-ready-y-window-load-en-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convertir cadenas de texto en números en Javascript</title>
		<link>http://www.masquewordpress.com/convertir-cadenas-de-texto-en-numeros-en-javascript/</link>
		<comments>http://www.masquewordpress.com/convertir-cadenas-de-texto-en-numeros-en-javascript/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 13:24:12 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tutorial jquery]]></category>

		<guid isPermaLink="false">http://www.masquewordpress.com/?p=910</guid>
		<description><![CDATA[Sencillas funciones que no por ello son menos importantes para poder convertir strings en int o floats. Aunque estas funciones son de Javascript las pueden emplear con jQuery o cualquier otro framework para convertir sus cadenas de texto en números y así poder restar, sumar o realizar cualquier otra operación que necesiten. Convertir string a [...]]]></description>
			<content:encoded><![CDATA[<p>Sencillas funciones que no por ello son menos importantes para poder convertir <strong>strings</strong> en <strong>int</strong> o <strong>floats</strong>. Aunque estas funciones son de <strong>Javascript</strong> las pueden emplear con jQuery o cualquier otro framework para convertir sus cadenas de texto en números y así poder restar, sumar o realizar cualquier otra operación que necesiten.<br />
<span id="more-910"></span></p>
<p>Convertir string a entero</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> texto <span style="color: #339933;">=</span> <span style="color: #3366CC;">'1234'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// text + 10 = 123410</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> numero<span style="color: #339933;">;</span>
numero <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>texto<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//numero= 1244</span></pre></td></tr></table></div>

<p>String a decimal:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> texto <span style="color: #339933;">=</span> <span style="color: #3366CC;">'1234.0987'</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//texto + 10 = 1234.098710</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> entero <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// entero = 1234</span>
<span style="color: #003366; font-weight: bold;">var</span> decimal <span style="color: #339933;">=</span> parseFloat<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// decimal = 1234.0987</span>
<span style="color: #006600; font-style: italic;">//decimal + 10 = 1244.098710</span></pre></td></tr></table></div>

<p>Reducir el número de decimales:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> numero <span style="color: #339933;">=</span> <span style="color: #CC0000;">1234.0987</span><span style="color: #339933;">;</span>
&nbsp;
numero <span style="color: #339933;">=</span> numero.<span style="color: #660066;">toFixed</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// numero = 1234.09</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/convertir-cadenas-de-texto-en-numeros-en-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contar o Limitar la cantidad de palabras con jQuery</title>
		<link>http://www.masquewordpress.com/contar-limitar-la-cantidad-de-palabras-con-jquery/</link>
		<comments>http://www.masquewordpress.com/contar-limitar-la-cantidad-de-palabras-con-jquery/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 14:02:47 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[tutorial jquery]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=846</guid>
		<description><![CDATA[Se acuerdan que el otro día creamos un plugin para limitar las letras de un textarea? Y que pasa si lo que necesitamos en limitar la cantidad de palabras? Aunque en principio no parezca de utilidad hay ocasiones donde necesitaremos hacerlo o simplemente necesitaremos contar la cantidad de palabras de un textarea para mostrarlo en [...]]]></description>
			<content:encoded><![CDATA[<p>Se acuerdan que el otro día <a href="http://masquewordpress.com/jquery/plugin-jquery-para-limitar-caracteres-en-un-campo-de-texto/">creamos un plugin para limitar las letras de un textarea?</a> Y que pasa si lo que necesitamos en limitar la cantidad de palabras? Aunque en principio no parezca de utilidad hay ocasiones donde necesitaremos hacerlo o simplemente necesitaremos <strong>contar la cantidad de palabras de un textarea</strong> para mostrarlo en un mensaje.</p>
<p><span id="more-846"></span></p>
<h3>Contar la cantidad de palabras de un textarea</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#textarea_id'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> palabras <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\b[\s,\.\-:;]*/</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">lenght</span><span style="color: #339933;">;</span>
     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#contador'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Has escrito en total '</span><span style="color: #339933;">+</span> palabras <span style="color: #339933;">+</span><span style="color: #3366CC;">' palabras'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Lo que hacemos en cada vez que se levanta una tecla(<strong>keyup</strong>) comprobamos el valor del textarea y lo dividimos(<strong>split</strong>) en palabras mediante la regla de regex que prácticamente se encarga de separar las palabras por espacios, guiones ,etc. Una vez que tenemos todas las palabras con <strong>lenght</strong> obtenemos la cantidad.<br />
Por último modificamos el campo contador con la cantidad de palabras de nuestro textarea.</p>
<h3>Limitar la cantidad de palabras de un textarea</h3>
<p>Para esto vamos a crear una nueva función</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> limitar_palabras<span style="color: #009900;">&#40;</span>texto<span style="color: #339933;">,</span> limite<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> palabras <span style="color: #339933;">=</span> texto.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\b[\s,\.\-:;]*/</span><span style="color: #339933;">,</span>limite<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
texto<span style="color: #339933;">=</span>palabras.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">return</span> texto<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>En esta función añadimos la <strong>variable limite</strong> al <strong>.split</strong> y luego unimos el resultado con espacios usando <strong>.join</strong>.</p>
<p>Por lo que el código todo junto quedaría de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#textarea_id'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>limitar_palabras<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> limitar_palabras<span style="color: #009900;">&#40;</span>texto<span style="color: #339933;">,</span> limite<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> palabras <span style="color: #339933;">=</span> texto.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\b[\s,\.\-:;]*/</span><span style="color: #339933;">,</span>limite<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    texto<span style="color: #339933;">=</span>palabras.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> texto<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Facil y sencillo verdad? Porque no prueban a crear su<a href="http://masquewordpress.com/category/jquery/"> propio plugin de jQuery</a> con estos sencillos pasos? Saludos!!</p>
<p>&nbsp;</p>
<p>Actualizado<div class="iconbox"><span class="iconbox_icon"><img src='http://www.masquewordpress.com/wp-content/themes/brightbox/images/icons/iconbox/info.png' alt='' /></span><div class="iconbox_content"><h3 class="iconbox_content_title">Actualización</h3><p>He cambiado el regex para que también detecte números como palabras . Ahora &#8220;-&#8221; esta &#8220;\-&#8221;. </p>
</div></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/contar-limitar-la-cantidad-de-palabras-con-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>63 Tutoriales de Diseño Web, jQuery, WordPress y un montón más</title>
		<link>http://www.masquewordpress.com/63-tutoriales-de-diseno-web-jquery-wordpress-y-un-monton-mas/</link>
		<comments>http://www.masquewordpress.com/63-tutoriales-de-diseno-web-jquery-wordpress-y-un-monton-mas/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 14:30:48 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[Noticias]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=819</guid>
		<description><![CDATA[63 Tutoriales de Diseño Web, jQuery, WordPress y un montón más es la cantidad reunida hasta día de hoy en mi blog. Eso sin contar los &#8220;pequeños trucos o tips&#8221; que son demasiado cortos para contarlos como tutoriales. Alguien quiere colaborar con un tutorial propio? Saludos!!]]></description>
			<content:encoded><![CDATA[<p><a href="http://masquewordpress.com/tutoriales/">63 Tutoriales de Diseño Web, jQuery, WordPress y un montón más</a> es la cantidad reunida hasta día de hoy en mi blog. Eso sin contar los &#8220;pequeños trucos o tips&#8221; que son demasiado cortos para contarlos como tutoriales.</p>
<p>Alguien quiere colaborar con un tutorial propio?</p>
<p>Saludos!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/63-tutoriales-de-diseno-web-jquery-wordpress-y-un-monton-mas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Plugin jQuery para limitar caracteres en un campo de texto</title>
		<link>http://www.masquewordpress.com/plugin-jquery-para-limitar-caracteres-en-un-campo-de-texto/</link>
		<comments>http://www.masquewordpress.com/plugin-jquery-para-limitar-caracteres-en-un-campo-de-texto/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 15:36:02 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[jquery.plugin]]></category>
		<category><![CDATA[tutorial jquery]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=811</guid>
		<description><![CDATA[[offtopic] Antes de empezar este artículo quiero dar mis condolencias a la Familia Jobs. Para mi Steve Jobs siempre fue un grande , incluso antes de enamorarme de sus productos y SO. Siempre recomiendo ver un discurso dado por el para los alumnos de Standford Bridge. Lo pueden encontrar en http://www.youtube.com/watch?feature=player_embedded&#38;v=14v3kV47oZU [/offtopic] Hoy les voy [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>[offtopic] Antes de empezar este artículo quiero dar mis condolencias a la Familia Jobs. Para mi Steve Jobs siempre fue un grande , incluso antes de enamorarme de sus productos y SO. Siempre recomiendo ver un discurso dado por el para los alumnos de Standford Bridge. Lo pueden encontrar en http://www.youtube.com/watch?feature=player_embedded&amp;v=14v3kV47oZU [/offtopic]</p></blockquote>
<p>Hoy les voy a enseñar 2 cosas. <strong>Como limitar los caracteres de un campo de texto ya sea un textarea o un input</strong> y <strong>como crear un plugin de Jquery</strong>.<br />
<span id="more-811"></span><br />
Lo primero que necesitamos en un nuevo formulario dentro de una <strong>página HTML</strong> y le vamos a agregar un <strong>etiqueta span</strong> que será donde mostremos los caracteres que nos quedan con <strong>id=&#8221;counter&#8221;</strong>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE  HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;  &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
   &lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script  type=&quot;text/javascript&quot;&gt;
        $(document).ready(function() {
        //Nuestras funciones jQuery
        });
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form  id=&quot;formulario&quot;  method=&quot;POST&quot; action=&quot;?&quot;&gt;
    &lt;textarea  id=&quot;text&quot;&gt;&lt;/textarea&gt;
    &lt;span  id=&quot;counter&quot;&gt;&lt;/span&gt;
    &lt;input type=&quot;submit&quot;  value=&quot;submit&quot;&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Ahora escribamos nuestra función para mostrar cuantos caracteres nos quedan.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> caracteres<span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span> caracteres<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Creamos una función que en el evento keyup que compruebe que la cantidad de caracteres escritos no es mayor que el limite que establecimos anteriormente. En caso contrario borra el valor de campo que excede dicho limite:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#text&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Explicando un poco esta función vemos que cada vez que se levanta el dedo de un tecla <strong>obtenemos el length(cantidad)</strong> de caracteres del <strong>valor(val)</strong> de nuestro campo de texto y lo comparamos con la cantidad estipulada anteriormente.<br />
Si es mayor el valor del campo es sustituido por el valor actual menos el limite estipulado. Es decir, con la <strong>función substr</strong> recortamos la cadena de texto desde el caracter 0 hasta 100 y el resultado sustituye el valor del campo de texto.</p>
<p>Ahora cambiemos la frase de nuestro counter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span>  quedan <span style="color: #339933;">=</span> caracteres <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span> quedan<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Aquí solamente restamos el limite establecido menos la cantidad de caracteres de nuestro campo.</p>
<p>Y si queremos agregarle un toque de color podemos hacer lo siguiente:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>quedan <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;color&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;red&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;color&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;black&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Si nos quedan menos de diez caracteres , nuestro mensaje se volvera rojo!</p>
<p>El script entero entonces queda de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> caracteres <span style="color: #339933;">=</span> <span style="color: #CC0000;">220</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span>  caracteres<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#text&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #003366; font-weight: bold;">var</span> quedan <span style="color: #339933;">=</span> caracteres <span style="color: #339933;">-</span>  $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span>  quedan<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>quedan <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;color&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;red&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span>
    <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#counter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;color&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;black&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Pueden ver el ejemplo funcionando en <a href="http://jsfiddle.net/sa4HH/">http://jsfiddle.net/sa4HH/</a></strong></p>
<h3>Crear un Plugin jQuery para delimitar los campos de texto</h3>
<p>Por lo general vamos a necesitar este código en más de una ocasión y para varios campos de texto, por lo que repetir todo una y otra vez no es aceptable. En este caso nos conviene crear un simple plugin de jQuery que será facil de aplicar.<br />
Para ello siguiendo la lógica de jQuery vamos a crear la base de nuestro plugin que lo vamos a llamar <strong>&#8220;limitar&#8221;</strong>:<br />
¡</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">limitar</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      defaults <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        limite<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span>
        id_counter<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
        clase_alert<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>
     <span style="color: #009900;">&#125;</span>
   <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>defaults<span style="color: #339933;">,</span>  options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Al declarar nuestro <strong>plugin limitar</strong> hemos creado unos valores por defecto que paso a explicar.</p>
<ul>
<li><strong>limite</strong>: Es el límite por defecto. En este caso <strong>200</strong> caracteres.</li>
<li><strong>id_counter</strong>: Es el id del campo donde mostraremos el mensaje de caracteres faltantes. Por defecto es <strong>false</strong>, por lo que no mostraríamos ningún mensaje.</li>
<li><strong>clase_alert</strong>: En lugar de cambiar el color si los caracteres son menos que diez vamos a asignarle un clase para así dar más libertad a la hora de aplicar estilo a este mensaje de alerta. Por defecto no se asigna ninguna clase ya que es <strong>false</strong>.</li>
</ul>
<p>Ahora debemos terminar la función de nuestro plugin:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> caracteres <span style="color: #339933;">=</span> options.<span style="color: #660066;">limite</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">id_counter</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span> caracteres <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">id_counter</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> quedan <span style="color: #339933;">=</span>  caracteres <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span> quedan <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>quedan <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">clase_alert</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span>
            <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">clase_alert</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Estamos replicando nuestra función del principio con la única diferencia que usamos los valores dentro del array <strong>options</strong> para dar más flexibilidad al código y miren que sin por ejemplo <strong>options.id_counter es false</strong> nunca mostraremos el mensaje.</p>
<p>El plugin entero que debemos guardar como jquery.limitar.js quedaría de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">limitar</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      defaults <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        limite<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span>
        id_counter<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
        clase_alert<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>
     <span style="color: #009900;">&#125;</span>
   <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>defaults<span style="color: #339933;">,</span>  options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> caracteres <span style="color: #339933;">=</span> options.<span style="color: #660066;">limite</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">id_counter</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span> caracteres <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> caracteres<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">id_counter</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> quedan <span style="color: #339933;">=</span>  caracteres <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Te quedan &lt;strong&gt;&quot;</span><span style="color: #339933;">+</span> quedan <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/strong&gt; caracteres&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>quedan <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">clase_alert</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span>
            <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>options.<span style="color: #660066;">id_counter</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">clase_alert</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Para usarlo tan solo debemos llamarlo de la siguiente manera (no se olviden de crear la clase para dar estilo al mensaje de alerta):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script  type=&quot;text/javascript&quot; src=&quot;jquery.limit.js&quot;&gt;&lt;/script&gt;
&lt;style&gt;
.alert{
    color: red;
    font-weight:bold;
}
&lt;/style&gt;
&lt;script  type=&quot;text/javascript&quot;&gt;
    $(document).ready(function() {
        $(&quot;#testo&quot;).limitar({
            limite: 100,
            id_counter: &quot;counter&quot;,
            clase_alert: &quot;alert&quot;
            });
         });
&lt;/script&gt;</pre></td></tr></table></div>

<p>Pueden ver el ejemplo funcionando en <a href="http://jsfiddle.net/V7Gs6/1/">http://jsfiddle.net/V7Gs6/1/</a></p>
<p>Saludos!!!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/plugin-jquery-para-limitar-caracteres-en-un-campo-de-texto/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tabs en JQuery y reconocimiento de hashtags</title>
		<link>http://www.masquewordpress.com/tabs-en-jquery-y-reconocimiento-de-hashtags/</link>
		<comments>http://www.masquewordpress.com/tabs-en-jquery-y-reconocimiento-de-hashtags/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 22:37:58 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[hashtag]]></category>
		<category><![CDATA[tabs]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=697</guid>
		<description><![CDATA[Hace mucho que no pongo un tutorial de JQuery en la web, así que hoy voy a explicarles como se puede animar unas tabs (pestañas) con JQuery con unas pocas lineas de código y un poco de CSS. Este tutorial es bastante sencillo y se me ocurrió hacerlo porque estoy trabajando en un artículo sobre [...]]]></description>
			<content:encoded><![CDATA[<p>Hace mucho que no pongo un <a href="http://masquewordpress.com/tutoriales/">tutorial</a> de <a href="http://masquewordpress.com/tag/jquery/">JQuery</a> en la web, así que hoy voy a explicarles como se puede animar unas tabs (pestañas) con JQuery con unas pocas lineas de código y un poco de CSS.</p>
<p>Este tutorial es bastante sencillo y se me ocurrió hacerlo porque estoy trabajando en un artículo sobre como crear una aplicación para <a href="http://masquewordpress.com/tag/twitter/">Twitter</a> con PHP en el cual necesito hacer unas tabs bastante sencillas. Pero no nos adelantemos y vamos a ver como crear tabs con JQuery y CSS.</p>
<p><span id="more-697"></span></p>
<div id="ejemplo">
<div class="wrap-ej"><a href="http://masquewordpress.com/ejemplos/tabs-en-jquery.zip" class="descarga"></a><a href="http://masquewordpress.com/ejemplos/tabs-en-jquery/" class="demo"></a></div>
</div>
<h3>Lo primero que necesitamos es la estructura HTML :</h3>
<p>Hay que tener en cuenta que vamos a mostrar contenido por defecto por lo que hay que aplicar la clase <strong>&#8220;active&#8221;</strong> a la pestaña activa y ocultar el contenido que no queremos mostrar con <strong>&#8220;display:none;&#8221;</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tabs&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>  <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;active&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#tab1&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#tab2&quot;</span>&gt;</span>Galería<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#tab3&quot;</span>&gt;</span>Contacto<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab_container&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab1&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab_content&quot;</span>&gt;</span>
        <span style="color: #808080; font-style: italic;">&lt;!--Contenido--&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab_content&quot;</span>  <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display:none;&quot;</span>&gt;</span>
       <span style="color: #808080; font-style: italic;">&lt;!--Contenido--&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab3&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tab_content&quot;</span>  <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display:none;&quot;</span>&gt;</span>
       <span style="color: #808080; font-style: italic;">&lt;!--Contenido--&gt;</span>
     <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<h3>Aplicando estilo</h3>
<p>De momento solo tenemos una lista y un par de divs. Vamos a aplicarle un poco de estilo con CSS:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul<span style="color: #6666ff;">.tabs</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">32px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.tabs</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">31px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">31px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#e0e0e0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.tabs</span> li a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.tabs</span> li a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
html ul<span style="color: #6666ff;">.tabs</span> li<span style="color: #6666ff;">.active</span><span style="color: #00AA00;">,</span> html ul<span style="color: #6666ff;">.tabs</span> li<span style="color: #6666ff;">.active</span> a<span style="color: #3333ff;">:hover  </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.tab_container</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.tab_content</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Incluyendo JQuery</h3>
<p>Incluimos JQuery como hacemos siempre.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<h3> La magia de JQuery</h3>
<p>Por último añadimos el script JQuery que será el encargado de darle vida a nuestras <a href="http://masquewordpress.com/ejemplos/tabs-en-jquery/">tabs con JQuery y CSS</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.tabs li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>     <span style="color: #006600; font-style: italic;">//cada vez que se hace click en un li</span>
       <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.tabs li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//removemos clase active de todos</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//añadimos a la actual la clase active</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tab_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//escondemos todo el contenido</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//obtenemos atributo href del link</span>
		$<span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// mostramos el contenido</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//devolvemos false para el evento click</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Como ven con unas pocas lineas de código tenemos <a href="http://masquewordpress.com/ejemplos/tabs-en-jquery/">tabs en jquery</a></p>
<h3> Reconocer links con hashtags como twitter </h3>
<p>Sacando un poco más de jugo a este script podemos añadir una función que detecte los hashtags  en los links.<br />
Por ejemplo si pasamos el link <a href="http://masquewordpress.com/ejemplos/tabs-en-jquery/#tab3">http://masquewordpress.com/ejemplos/tabs-en-jquery/#tab3</a> queremos que nos muestre el contenido de la tercera pestaña.<br />
Con el siguiente código podemos conseguirlo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #003366; font-weight: bold;">var</span> hash <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">hash</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//recuperamos el hashtag del link</span>
	<span style="color: #003366; font-weight: bold;">var</span> href <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul.tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//pasamos por todos los tabs</span>
		<span style="color: #003366; font-weight: bold;">var</span> href <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//recuperamos atributo href</span>
		href<span style="color: #339933;">=</span>href.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//retiramos # </span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">==</span>href<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//comprobamos que el hash sea igual que el atributo de la pestaña</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tab_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">//escondemos todo</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.tabs li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//desactivamos pestañas</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//activamos pestaña actual</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span><span style="color: #339933;">+</span>hash<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// mostramos contenido requerido</span>
		<span style="color: #009900;">&#125;</span>											
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<h3>Todo el código javascript junto sería</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> hash <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">hash</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> href <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul.tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> href <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		href<span style="color: #339933;">=</span>href.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>hash<span style="color: #339933;">==</span>href<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tab_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.tabs li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span><span style="color: #339933;">+</span>hash<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>											
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.tabs li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
       <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.tabs li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tab_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Como siempre dejen sus dudas en los comentarios. Saludos!!!</p>
<div id="ejemplo">
<div class="wrap-ej"><a href="http://masquewordpress.com/ejemplos/tabs-en-jquery.zip" class="descarga"></a><a href="http://masquewordpress.com/ejemplos/tabs-en-jquery/" class="demo"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/tabs-en-jquery-y-reconocimiento-de-hashtags/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introducción  a JQuery Template plugin jquery.tmpl.js</title>
		<link>http://www.masquewordpress.com/introduccion-a-jquery-template-plugin-jquery-tmpl-js/</link>
		<comments>http://www.masquewordpress.com/introduccion-a-jquery-template-plugin-jquery-tmpl-js/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 22:28:52 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jquery.plugin]]></category>
		<category><![CDATA[jquery.tmpl.js]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=667</guid>
		<description><![CDATA[Hace poco el equipo de JQuery anuncio que el  plugin de templates de Microsoft es ahora soportado oficialmente. Esto quiere decir que el propio equipo de JQuery se va a encargar de su desarollo y actualizaciones. A continuación les explico como integrarlo y usarlo de una forma sencilla. Para este ejemplo vamos a utilizar mis [...]]]></description>
			<content:encoded><![CDATA[<p>Hace poco el equipo de JQuery <a href="http://api.jquery.com/category/plugins/templates/">anuncio</a> que el  <a href="http://github.com/jquery/jquery-tmpl">plugin de templates</a> de Microsoft es ahora soportado oficialmente. Esto quiere decir que el propio equipo de JQuery se va a encargar de su desarollo y actualizaciones. A continuación les explico como integrarlo y usarlo de una forma sencilla.</p>
<p><span id="more-667"></span></p>
<div id="ejemplo">
<div class="wrap-ej"><a href="http://masquewordpress.com/ejemplos/jquery-templates.zip" class="descarga"></a><a href="http://masquewordpress.com/ejemplos/jquery-templates/" class="demo"></a></div>
</div>
<p>Para este ejemplo vamos a utilizar <a href="http://masquewordpress.com/tag/twitter">mis últimos tweets en Twitter</a> de manera que sirvan para rellenar el template que vamos a crear previamente.</p>
<h3>1. El primer paso es <a href="http://masquewordpress.com/recursos/como-mejorar-velocidad-carga-pagina-web/">integrar JQuery</a> y el plugin de templates</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>  
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.tmpl.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<h3>2. Creamos el template</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tweets&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/x-jquery-tmpl&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${imgSource}&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${username}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span> ${username} <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span> ${tweet} <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		{{if geo}}
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span> ${geo} <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
		{{/if}}
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p>Cabe destacar que:</p>
<ul>
<li>Nuestro template se encuentra dentro de las tags <strong>&lt;script&gt;</strong> y el type usado es <strong>text/x-jquery-tmpl</strong></li>
<li>Las variables tienen el siguiente formato <strong>${</strong>nombreDeVariable<strong><span><span>}</span></span></strong></li>
<li><span><span>Se pueden crear <strong>sentencias if</strong> de la siguiente manera</span></span><strong><span><span> {{if </span></span></strong><span><span>condicion</span></span><strong><span><span>}</span></span></strong><strong><span><span>}</span></span></strong><strong><span><span> </span></span></strong><span><span>sentencia a ejecutar</span></span><strong><span><span> {{/if</span></span></strong><strong><span><span>}</span></span></strong><strong><span><span>}</span></span></strong></li>
</ul>
<h3>3. Buscamos algun dato para renderizar en nuestro template</h3>
<p>En este caso usando la SEARCH API de Twitter obtenemos los últimos resultados donde mencionan <a href="http://twitter.com/chifliiiii">mi cuenta de twitter</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
 $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    type <span style="color: #339933;">:</span> <span style="color: #3366CC;">'GET'</span><span style="color: #339933;">,</span>
    dataType <span style="color: #339933;">:</span> <span style="color: #3366CC;">'jsonp'</span><span style="color: #339933;">,</span>
    url <span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://search.twitter.com/search.json?q=chifliiiii'</span><span style="color: #339933;">,</span>
&nbsp;
    success <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tweets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003366; font-weight: bold;">var</span> twitter <span style="color: #339933;">=</span> $.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span>tweets.<span style="color: #660066;">results</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
             username <span style="color: #339933;">:</span> obj.<span style="color: #660066;">from_user</span><span style="color: #339933;">,</span>
             tweet <span style="color: #339933;">:</span> obj.<span style="color: #660066;">text</span><span style="color: #339933;">,</span>
             imgSource <span style="color: #339933;">:</span> obj.<span style="color: #660066;">profile_image_url</span><span style="color: #339933;">,</span>
             geo <span style="color: #339933;">:</span> obj.<span style="color: #660066;">geo</span>
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Como veran usamos las variables definidas en el paso anterior para almacenar los varoles devueltos.</p>
<h3>4. Creamos el espacio donde actuara nuestra template</h3>
<p>Si recuerdan nuestra template no era más que un elemento <strong>&lt;li&gt;</strong> de una lista desordenada. Por lo que debemos crear dicha lista.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tweets&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></td></tr></table></div>

<h3>5. Enlazamos los datos al template y lo introducimos a la lista</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tweets'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tmpl</span><span style="color: #009900;">&#40;</span>twitter<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#twitter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ul>
<li>Seleccionamos el script (template) con id = tweets </li>
<li> Le pasamos el array twitter creado con .map al template </li>
<li> Añadimos lo anterior a la lista con id twitter</li>
</ul>
<p>Y con eso ya estaría todo en su sitio de manera que todo junto quedaría de la siguiente forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style.css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.tmpl.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span> Algunos tweets de mi cuenta <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tweets&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/x-jquery-tmpl&quot;</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${imgSource}&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${userName}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span> ${username} <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span> ${tweet} <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
&nbsp;
            {{if geo}}
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
               ${geo}
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
            {{/if}}
         <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;twitter&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
         $.ajax({
            type : 'GET',
            dataType : 'jsonp',
            url : 'http://search.twitter.com/search.json?q=chifliiiii',
&nbsp;
            success : function(tweets) {
               var twitter = $.map(tweets.results, function(obj, index) {
                  return {
                     username : obj.from_user,
                     tweet : obj.text,
                     imgSource : obj.profile_image_url,
                     geo : obj.geo
                  };
               });
&nbsp;
               $('#tweets').tmpl(twitter).appendTo('#twitter');
            }
      });
&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>Un saludo y hasta la proxima!!!</p>
<div id="ejemplo">
<div class="wrap-ej"><a href="http://masquewordpress.com/ejemplos/jquery-templates.zip" class="descarga"></a><a href="http://masquewordpress.com/ejemplos/jquery-templates/" class="demo"></a></div>
</div>
<p>Via | <a href="http://net.tutsplus.com/">Nettuts+</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/introduccion-a-jquery-template-plugin-jquery-tmpl-js/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JQuery Playground con Test it Yourself</title>
		<link>http://www.masquewordpress.com/jquery-playground-con-test-it-yourself/</link>
		<comments>http://www.masquewordpress.com/jquery-playground-con-test-it-yourself/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 13:39:48 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[plugins wordpress]]></category>
		<category><![CDATA[test it yourself]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=614</guid>
		<description><![CDATA[Hoy les traigo algo un poco diferente a lo acostumbrado, un &#8220;JQuery Playground&#8221; para los que están conociendo JQuery así pueden ver algunos efectos y animaciones que pueden hacer con este fabuloso Framework, jugar con las opciones que brinda y aprender porque no un poco más. Y ya que estamos promociono un poco mi plugin [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy les traigo algo un poco diferente a lo acostumbrado, un <strong>&#8220;JQuery Playground&#8221;</strong> para los que están conociendo <a href="http://jquery.com">JQuery</a> así pueden ver algunos efectos y animaciones que pueden hacer con este fabuloso Framework, jugar con las opciones que brinda y aprender porque no un poco más.<br />
Y ya que estamos promociono un poco mi plugin de Wordpres <a href="http://masquewordpress.com/wordpress/test-it-yourself-plugin-para-wordpress/">Test it Yourself</a> que la verdad no tubo más que unas pocas descargas desde que lo lance <img src='http://www.masquewordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Para &#8220;jugar&#8221; con los ejemplos de <strong>JQuery </strong>tan solo tiene que hacer click en <strong>&#8220;Test it&#8221;</strong> para cargar el código y ver como funciona.</p>
<p>Si se animan pueden dejar sus propias obras de arte en los comentarios <img src='http://www.masquewordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
<span id="more-614"></span></p>
<h2>JQuery <a href="http://api.jquery.com/animate/">.animate()</a> </h2>

   <script type="text/javascript">
$(document).ready(function () {
	$("#clear__tiy_0").click( function() {
		$("#input_tiy_0").val("");
		$("#output_tiy_0").attr("src","about:blank");
	});
});
</script>
   <div class="testiy" >
   <form id="tester_tiy_0" target="output_tiy_0" method="post" action="http://www.masquewordpress.com/wp-content/plugins/test-it-yourself/show.php">


<textarea id="input_tiy_0" wrap="logical" cols="90" rows="12" name="input" class="input">
<head>
<style>
div { 
background-color:#bca; 
width:100px; 
border:1px solid green;
position:absolute;
}
</style>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <button id="go">Run</button><button id="left">&laquo;</button> <button id="right">&raquo;</button>
<div id="block">Hola!!</div>

<script>
$("#go").click(function(){
  $("#block").animate({ 
    width: "70%",
    opacity: 0.4,
    marginLeft: "0.6in",
    fontSize: "3em", 
    borderWidth: "10px"
  }, 1500 );
});

$("#right").click(function(){
  $("#block").animate({"left": "+=50px"}, "slow");
});

$("#left").click(function(){
  $("#block").animate({"left": "-=50px"}, "slow");
});

</script>

</body>

</textarea>

	<p>
		<input class="inputbutton" id="exec_tiy_0" value="Test It" type="submit" /> <input class="inputbutton" id="clear__tiy_0" value="Clear All" type="submit" />
	</p>
	
	<iframe id="output_tiy_0" src="about:blank" name="output_tiy_0" class="output" frameborder="0"> </iframe>
	</form>	
   
   
   
   </div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>JQuery <a href="http://api.jquery.com/fadeIn/">.fadeIn()</a> y JQuery<a href="http://api.jquery.com/fadeOut/"> .fadeOut()</a> </h2>

   <script type="text/javascript">
$(document).ready(function () {
	$("#clear__tiy_1").click( function() {
		$("#input_tiy_1").val("");
		$("#output_tiy_1").attr("src","about:blank");
	});
});
</script>
   <div class="testiy" >
   <form id="tester_tiy_1" target="output_tiy_1" method="post" action="http://www.masquewordpress.com/wp-content/plugins/test-it-yourself/show.php">


<textarea id="input_tiy_1" wrap="logical" cols="90" rows="12" name="input" class="input">
<head>
<style>
    span { color:red; cursor:pointer; }
    div { margin:3px; width:80px; display:none;
      height:80px; float:left; }
      div#one { background:#f00; }
      div#two { background:#0f0; }
      div#three { background:#00f; }
    </style>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <span id="boton">Hace Click aca&#8230;</span> <span id="boton2">O hace Click aca&#8230;</span>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>

<script>
      $("#boton").click(function () {
        $("div:hidden:first").fadeIn("slow");
      });
 $("#boton2").click(function () {
        $("div:block:first").fadeOut("slow");
      });
    </script>

</body>

</textarea>

	<p>
		<input class="inputbutton" id="exec_tiy_1" value="Test It" type="submit" /> <input class="inputbutton" id="clear__tiy_1" value="Clear All" type="submit" />
	</p>
	
	<iframe id="output_tiy_1" src="about:blank" name="output_tiy_1" class="output" frameborder="0"> </iframe>
	</form>	
   
   
   
   </div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>JQuery <a href="http://api.jquery.com/show/">.show()</a> y  JQuery <a href="http://api.jquery.com/hide/">.hide()</a></h2>

   <script type="text/javascript">
$(document).ready(function () {
	$("#clear__tiy_2").click( function() {
		$("#input_tiy_2").val("");
		$("#output_tiy_2").attr("src","about:blank");
	});
});
</script>
   <div class="testiy" >
   <form id="tester_tiy_2" target="output_tiy_2" method="post" action="http://www.masquewordpress.com/wp-content/plugins/test-it-yourself/show.php">


<textarea id="input_tiy_2" wrap="logical" cols="90" rows="12" name="input" class="input">
<head>
<style>
      div { background:yellow;width:100px;height:100px; }
      </style>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <button class="1">Show it</button> <button class="2">Hide it</button>
<div style="display: none">Hola!!

<script>
    $(".1").click(function () {
    $("div").show("slow");
    });
 $(".2").click(function () {
    $("div").hide("slow");
    });
    </script>

</body>


</textarea>

	<p>
		<input class="inputbutton" id="exec_tiy_2" value="Test It" type="submit" /> <input class="inputbutton" id="clear__tiy_2" value="Clear All" type="submit" />
	</p>
	
	<iframe id="output_tiy_2" src="about:blank" name="output_tiy_2" class="output" frameborder="0"> </iframe>
	</form>	
   
   
   
   </div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>JQuery <a href="http://api.jquery.com/slideUp/">.slideUp()</a> y  JQuery <a href="http://api.jquery.com/slideDown/">.slideDown()</a></h2>

   <script type="text/javascript">
$(document).ready(function () {
	$("#clear__tiy_3").click( function() {
		$("#input_tiy_3").val("");
		$("#output_tiy_3").attr("src","about:blank");
	});
});
</script>
   <div class="testiy" >
   <form id="tester_tiy_3" target="output_tiy_3" method="post" action="http://www.masquewordpress.com/wp-content/plugins/test-it-yourself/show.php">


<textarea id="input_tiy_3" wrap="logical" cols="90" rows="12" name="input" class="input">
<head>
<style>
  div { background:#3d9a44; margin:3px; width:80px; 
    height:40px; float:left; }
  </style>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <button>Up</button>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>

<script>
  $("button").click(function () {
    if ($("div:first").is(":hidden")) {
      $("div").slideDown("slow");
      $("button").html("Up");
    } else {
      $("div").slideUp();
$("button").html("Down");
    }
  });

  </script>

</body>


</textarea>

	<p>
		<input class="inputbutton" id="exec_tiy_3" value="Test It" type="submit" /> <input class="inputbutton" id="clear__tiy_3" value="Clear All" type="submit" />
	</p>
	
	<iframe id="output_tiy_3" src="about:blank" name="output_tiy_3" class="output" frameborder="0"> </iframe>
	</form>	
   
   
   
   </div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2><a href="http://masquewordpress.com/jquery/como-seleccionar-deseleccionar-todos-los-checkbox-con-jquery/">Como seleccionar / deseleccionar todos los checkbox con JQuery</a></h2>

   <script type="text/javascript">
$(document).ready(function () {
	$("#clear__tiy_4").click( function() {
		$("#input_tiy_4").val("");
		$("#output_tiy_4").attr("src","about:blank");
	});
});
</script>
   <div class="testiy" >
   <form id="tester_tiy_4" target="output_tiy_4" method="post" action="http://www.masquewordpress.com/wp-content/plugins/test-it-yourself/show.php">


<textarea id="input_tiy_4" wrap="logical" cols="90" rows="12" name="input" class="input">
<head>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
function checkTodos (id,pID) {

                   $( "#" + pID + " :checkbox").attr('checked', $('#' + id).is(':checked'));

            }
</script>
</head>
<body>
<div id="tipos_trabajo" style="display: block;">
<form id="search_form" action="busquedas.php" accept-charset="utf-8" method="post">
             //Boton que se encarga de seleccionar/ deseleccionar los checkbox
<input id="checkAll" onclick="checkTodos(this.id,'tipos_trabajo');" name="checkAll" type="checkbox" />
<ul>
<li name="tipotrabajo">
<input class="check" type="checkbox" value="1" name="tipotrabajo[]"/>
                           Caldereria
                  </li>
<li name="tipotrabajo">
<input class="check" type="checkbox" value="2" name="tipotrabajo[]"/>
                           Electricidad
                  </li>
<li name="tipotrabajo">
<input class="check" type="checkbox" value="3" name="tipotrabajo[]"/>
                           Redes
                  </li>
<li name="tipotrabajo">
<input class="check" type="checkbox" value="10" name="tipotrabajo[]"/>
                           Carpinteria
                  </li>
<li name="tipotrabajo">
<input class="check" type="checkbox" value="15" name="tipotrabajo[]"/>
                           Mecánica
                  </li>
</ul></form>
</div>

</body>


</textarea>

	<p>
		<input class="inputbutton" id="exec_tiy_4" value="Test It" type="submit" /> <input class="inputbutton" id="clear__tiy_4" value="Clear All" type="submit" />
	</p>
	
	<iframe id="output_tiy_4" src="about:blank" name="output_tiy_4" class="output" frameborder="0"> </iframe>
	</form>	
   
   
   
   </div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2><a href="http://masquewordpress.com/recursos/7-codigos-jquery-que-todos-deberian-tener/"><br />
Placeholder para cajas de búsquedas que desaparece</a></h2>

   <script type="text/javascript">
$(document).ready(function () {
	$("#clear__tiy_5").click( function() {
		$("#input_tiy_5").val("");
		$("#output_tiy_5").attr("src","about:blank");
	});
});
</script>
   <div class="testiy" >
   <form id="tester_tiy_5" target="output_tiy_5" method="post" action="http://www.masquewordpress.com/wp-content/plugins/test-it-yourself/show.php">


<textarea id="input_tiy_5" wrap="logical" cols="90" rows="12" name="input" class="input">
<head>
<style>
#searchbox{color:#ccc;}
</style>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){

var texto="Introduce tu búsqueda";
 $("#searchbox").val(texto).focus(function(){$(this).val('');}).blur(function(){
 ($(this).val() === '')? $(this).val(texto) : null;
 });
});
</script>
</head>
<body>
<input type="search" id="searchbox"></input>

</body>


</textarea>

	<p>
		<input class="inputbutton" id="exec_tiy_5" value="Test It" type="submit" /> <input class="inputbutton" id="clear__tiy_5" value="Clear All" type="submit" />
	</p>
	
	<iframe id="output_tiy_5" src="about:blank" name="output_tiy_5" class="output" frameborder="0"> </iframe>
	</form>	
   
   
   
   </div>
<p>Bueno que les pareció hasta ahí? Si dejan algún ejemplo interesante en los comentarios hacemos una segunda versión de JQuery Playground con los que se le ocurran a ustedes.<br />
Como siempre estoy abierto a sus dudas, sugerencias y críticas ( de estas últimas un poco menos <img src='http://www.masquewordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</p>
<p>Saludos!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/jquery-playground-con-test-it-yourself/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

