<?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>Linea de Codigo &#187; jQuery</title>
	<atom:link href="http://lineadecodigo.com/categoria/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://lineadecodigo.com</link>
	<description>/* Programación en la red */</description>
	<lastBuildDate>Tue, 22 May 2012 22:10:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Animar elementos con jQuery</title>
		<link>http://lineadecodigo.com/jquery/animar-elementos-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/animar-elementos-con-jquery/#comments</comments>
		<pubDate>Thu, 03 May 2012 13:11:50 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[duración]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[imagen]]></category>
		<category><![CDATA[mouseout]]></category>
		<category><![CDATA[mouseover]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=4131</guid>
		<description><![CDATA[Una cosa que podemos hacer de forma muy sencilla con jQuery es ejecutar animaciones de elementos. Y es que jQuery nos proporciona una función para animar elementos. Esta función es .animate(). Pero vamos por pasos. Lo primero será insertar el elemento que queremos animar. Por ejemplo, una imagen. Así que colocamos la imagen en la [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-4131'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/animar-elementos-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fanimar-elementos-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/animar-elementos-con-jquery/" data-count="horizontal" data-text="Animar elementos con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Una cosa que podemos hacer de forma muy sencilla con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> es ejecutar animaciones de elementos. Y es que <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> nos proporciona una función para animar elementos. Esta función es <a href="http://www.w3api.com/wiki/jQuery:Animate()" title="Método animate de jQuery">.animate()</a>.</p>
<p>Pero vamos por pasos. Lo primero será insertar el elemento que queremos animar. Por ejemplo, una imagen. Así que colocamos la imagen en la página.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:IMG"><span style="color: #000000; font-weight: bold;">img</span></a> <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contenido.png&quot;</span> <a href="http://w3api.com/wiki/HTML:alt"><span style="color: #000066;">alt</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span> <a href="http://w3api.com/wiki/HTML:height"><span style="color: #000066;">height</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50px&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre>
<p>Lo siguiente será decidir en qué momento queremos realizar la animación. En nuestro caso la secuencia será la siguiente. Cuando pasemos el ratón sobre la imagen agrandaremos dicha imagen. Y cuando salgamos de la imagen con el ratón, devolveremos la imagen al tamaño original.</p>
<p>Así que vamos a utilizar la gestión de eventos que nos proporcionan los métodos <a href="http://www.w3api.com/wiki/jQuery:Mouseover()" title="Evento mouseover de jQuery">.mouseover()</a> y <a href="http://www.w3api.com/wiki/jQuery:Mouseout()" title="Evento mouseout de jQuery">.mouseout()</a>. Será desde estos eventos dónde lancemos la animación.</p>
<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;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</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;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseout</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;">&#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>
<p>Vemos que  los métodos se lanzan sobre el elemento al que hemos dado el id "logo".</p>
<p>Ahora ya pasamos a realizar la animación de la imagen. Y como habíamos comentado al principio del artículo utilizaremos el método <a href="http://www.w3api.com/wiki/jQuery:Animate()" title="Método animate de jQuery">.animate()</a>.</p>
<p>El método <a href="http://www.w3api.com/wiki/jQuery:Animate()" title="Método animate de jQuery">.animate()</a> recibe como parámetros diferentes de cosas. Pero el primer parámetro, que es el más importante, recoge las propiedades que queremos modificar en el elemento para la animación. Pero vemos el resto.</p>
<pre>.animate( properties [, duration] [, easing] [, complete] )</pre>
<p>Vemos que además de los parámetros <a href="http://www.manualweb.net/tutorial-css/" title="Manual de CSS">CSS</a> a modificar podemos establecer: la duración, que indica en milisegundos cuánto tiempo durará la animación. La función que podemos ejecutar durante la animación es la que se referencia en el parámetro easing y con el parámetro complete podemos indicar qué función queremos ejecutar al finalizar la animación.</p>
<p>Pero volviendo a nuestro ejemplo, lo haremos de la forma más sencilla. Es decir, solo modificando las propiedades de la imagen. Como indicamos que al entrar con el ratón sobre la imagen la haríamos más grande, lo que vamos a realizar es incrementar su tamaño, es decir, su <a href="http://www.w3api.com/wiki/CSS:Height" title="Atributo Height de CSS">atributo height</a>. Y justamente lo contrario cuando salgamos de la imagen.</p>
<p>Así nuestro código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> quedará de la siguiente forma:</p>
<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;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</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;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #3366CC;">'150px'</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;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseout</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;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #3366CC;">'50px'</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: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Puedes probar el resto de propiedades del método animate, por ejemplo, si queremos hacer más lento cuando la imagen se haga grande.</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</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;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #3366CC;">'150px'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2000</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>
<p>¿Qué se te ocurre hacer con la función <a href="http://www.w3api.com/wiki/jQuery:Animate()" title="Método animate de jQuery">.animate()</a> de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>?<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/efecto-fade-en-jquery/" rel="bookmark" title="Marzo 30, 2012">Efecto Fade en jQuery</a></li>
<li><a href="http://lineadecodigo.com/javascript/cambiar-el-tamano-de-la-imagen-de-forma-dinamica/" rel="bookmark" title="Enero 12, 2007">Cambiar el tamaño de la imagen de forma dinamica</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-slide-con-jquery/" rel="bookmark" title="Enero 5, 2012">Efecto slide con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/eliminar-imagenes-rotas-con-jquery/" rel="bookmark" title="Octubre 12, 2010">Eliminar imágenes rotas con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/hola-mundo-con-jquery/" rel="bookmark" title="Enero 23, 2009">Hola Mundo con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 4.918 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_4131()',1000); }); </script><script type="text/javascript"> function loadGoogle1_4131(){ jQuery(document).ready(function($) { $('.dd-google1-4131').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/animar-elementos-con-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Aplicar opacidad con jQuery</title>
		<link>http://lineadecodigo.com/jquery/aplicar-opacidad-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/aplicar-opacidad-con-jquery/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 06:51:09 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[opacity]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=4048</guid>
		<description><![CDATA[jQuery nos permite modificar la opacidad de los elementos con una gran facilidad. Ya lo vimos haciendo un efecto de Fade. Pero ahora vamos a algo más sencillo, simplemente vamos a aplicar un cambio de opacidad de una imagen con jQuery. La idea será partir de una imagen y un enlace que nos permita aplicar [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-4048'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/aplicar-opacidad-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Faplicar-opacidad-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/aplicar-opacidad-con-jquery/" data-count="horizontal" data-text="Aplicar opacidad con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p><a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> nos permite modificar la opacidad de los elementos con una gran facilidad. Ya lo vimos <a href="http://lineadecodigo.com/jquery/efecto-fade-en-jquery/" title="Efecti Fade con jQuery">haciendo un efecto de Fade</a>.</p>
<p>Pero ahora vamos a algo más sencillo, simplemente vamos a aplicar un cambio de opacidad de una imagen con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>. La idea será partir de una imagen y un enlace que nos permita aplicar la opacidad.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:IMG"><span style="color: #000000; font-weight: bold;">img</span></a> <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contenido.png&quot;</span> <a href="http://w3api.com/wiki/HTML:alt"><span style="color: #000066;">alt</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;opacidad&quot;</span>&gt;</span>Opacidad<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></pre>
<p>Lo siguiente será capturar el evento click sobre ese enlace:</p>
<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;">&quot;#opacidad&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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//Código de cambio de opacidad</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>
<p>Y es que será en el <a href="http://www.w3api.com/wiki/jQuery:Click()" title="Evento Click de jQuery">evento click</a> dónde aplicaremos el cambio de opacidad. El cambio de opacidad se consigue modificando la propiedad opacity de CSS. Para ello vamos a utilizar el método <a href="http://www.w3api.com/wiki/jQuery:Css()" title="Método css de jQuery">.css</a> de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&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;opacity&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0.2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Es importante saber que los valores de la opacidad varian entre 0.0 y 1.0.</p>
<p>Ahora cuando pulsemos sobre el enlace aplicaremos la opacidad sobre la imagen habiendo utilizado <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/evitar-que-se-ejecute-un-evento-con-jquery/" rel="bookmark" title="Junio 11, 2010">Evitar que se ejecute un evento con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/hola-mundo-con-jquery/" rel="bookmark" title="Enero 23, 2009">Hola Mundo con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-fade-en-jquery/" rel="bookmark" title="Marzo 30, 2012">Efecto Fade en jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-slide-con-jquery/" rel="bookmark" title="Enero 5, 2012">Efecto slide con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/modificar-el-contenido-de-una-capa-con-jquery/" rel="bookmark" title="Mayo 27, 2010">Modificar el contenido de una capa con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 4.599 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_4048()',1000); }); </script><script type="text/javascript"> function loadGoogle1_4048(){ jQuery(document).ready(function($) { $('.dd-google1-4048').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/aplicar-opacidad-con-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Efecto Fade en jQuery</title>
		<link>http://lineadecodigo.com/jquery/efecto-fade-en-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/efecto-fade-en-jquery/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 06:00:42 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[fade]]></category>
		<category><![CDATA[fadeIn]]></category>
		<category><![CDATA[fadeOut]]></category>
		<category><![CDATA[onClick]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=4019</guid>
		<description><![CDATA[Utilizando jQuery podemos crear de una forma muy sencilla efectos de Fade, es decir, ocultar o mostrar un elemento de forma gradual. Para poder realizar un efecto de Fade en jQuery utilizaremos los métodos .FadeOut() y .FadeIn(). Pero lo primero será poner un elemento sobre el que aplicar el efecto Fade. En nuestro caso utilizaremos [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-4019'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/efecto-fade-en-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fefecto-fade-en-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/efecto-fade-en-jquery/" data-count="horizontal" data-text="Efecto Fade en jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Utilizando <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> podemos crear de una forma muy sencilla efectos de Fade, es decir, ocultar o mostrar un elemento de forma gradual. Para poder realizar un efecto de Fade en <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> utilizaremos los métodos <a href="http://www.w3api.com/wiki/jQuery:FadeOut()" title="Método fadeOut de jQuery">.FadeOut()</a> y <a href="http://www.w3api.com/wiki/jQuery:FadeIn()" title="Método fadeIn de jQuery">.FadeIn()</a>.</p>
<p>Pero lo primero será poner un elemento sobre el que aplicar el efecto Fade. En nuestro caso utilizaremos una imagen.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:IMG"><span style="color: #000000; font-weight: bold;">img</span></a> <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contenido.png&quot;</span> <a href="http://w3api.com/wiki/HTML:alt"><span style="color: #000066;">alt</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre>
<p>Ahora ponemos los enlaces para ocultar y mostrar:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ocultar&quot;</span>&gt;</span>Ocultar<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span> | <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mostrar&quot;</span>&gt;</span>Mostrar<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></pre>
<p>Lo que haremos ahora será poner el código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> que controle el evento onclick sobre estos enlaces. Para poder hacer esto necesitamos el <a href="http://www.w3api.com/wiki/jQuery:Click()" title="Método click de jQuery">método click</a> sobre los enlaces.</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mostrar&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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Efecto Fade</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Ya solo nos quedará el ejecutar los efecto con los métodos <a href="http://www.w3api.com/wiki/jQuery:FadeOut()" title="Método fadeOut de jQuery">.FadeOut()</a> y <a href="http://www.w3api.com/wiki/jQuery:FadeIn()" title="Método fadeIn de jQuery">.FadeIn()</a>.</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ocultar&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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</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;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mostrar&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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><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;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Si queremos podemos configurar el tiempo en el cual realizamos el efecto del face. Para ello pasaremos el tiempo, en milisegundos, a las funciones <a href="http://www.w3api.com/wiki/jQuery:FadeOut()" title="Método fadeOut de jQuery">.FadeOut()</a> y <a href="http://www.w3api.com/wiki/jQuery:FadeIn()" title="Método fadeIn de jQuery">.FadeIn()</a>.</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ocultar&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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2000</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;">&#40;</span><span style="color: #3366CC;">&quot;#mostrar&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>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#logo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2000</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>
<p>Algo sencillo realizar un efecto de fade en <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/aplicar-opacidad-con-jquery/" rel="bookmark" title="Abril 2, 2012">Aplicar opacidad con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-slide-con-jquery/" rel="bookmark" title="Enero 5, 2012">Efecto slide con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/usando-cookies-con-jquery/" rel="bookmark" title="Diciembre 28, 2009">Usando cookies con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/ocultar-y-mostrar-elementos-con-jquery/" rel="bookmark" title="Febrero 5, 2009">Ocultar y mostrar elementos con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/animar-elementos-con-jquery/" rel="bookmark" title="Mayo 3, 2012">Animar elementos con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 5.586 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_4019()',1000); }); </script><script type="text/javascript"> function loadGoogle1_4019(){ jQuery(document).ready(function($) { $('.dd-google1-4019').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/efecto-fade-en-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Crear un slider con jQuery</title>
		<link>http://lineadecodigo.com/jquery/crear-un-slider-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/crear-un-slider-con-jquery/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 07:00:04 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[modernizr]]></category>
		<category><![CDATA[Modernizr.load]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[polyfill]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3865</guid>
		<description><![CDATA[Ahora que hemos publicado un artículo sobre cómo montar un slider en HTML5 muchas de las preguntas que nos están llegando son relativas al no soporte del slider HTML5 en ciertos navegadores y consultas sobre cómo montar una alternativa. Lo que vamos a ver en este artículo es como crear un slider con jQuery. Y [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3865'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/crear-un-slider-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fcrear-un-slider-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/crear-un-slider-con-jquery/" data-count="horizontal" data-text="Crear un slider con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Ahora que hemos publicado un <a href="http://lineadecodigo.com/html5/elemento-rango-en-formularios-html5/" title="Crear un slider en HTML5">artículo sobre cómo montar un slider en HTML5</a> muchas de las preguntas que nos están llegando son relativas al no soporte del slider <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> en ciertos navegadores y consultas sobre cómo montar una alternativa.</p>
<p>Lo que vamos a ver en este artículo es como crear un slider con <a href="http://www.manualweb.net/tutorial-jquery/" title="Tutorial de jQuery">jQuery</a>. Y no es que <a href="http://www.manualweb.net/tutorial-jquery/" title="Tutorial de jQuery">jQuery</a> nos de un slider como elemento base de su lenguaje, si no que vamos a utilizar un <a href="https://github.com/freqdec/fd-slider" title="Plugin jd-slider de jQuery">plugin de jQuery para poder crear un slider</a>.</p>
<p>En concreto utilizamos <a href="https://github.com/freqdec/fd-slider" title="Plugin fd-slider de jQuery">el plugin fd-slider</a>. Además vamos a utilizar <a href="http://lineadecodigo.com/javascript/como-utilizar-un-polyfill-con-modernizr/" title="Utilizar un polyfill con Modernizr">la técnica de polyfills que vimos el otro día con el ejemplo sobre un placeholder</a>.</p>
<p>Lo bueno del <a href="https://github.com/freqdec/fd-slider" title="Plugin fd-slider de jQuery">plugin fd-slider</a> es que al ser un polyfill nos permite construir nuestra página con <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> y solo se ejecutará en aquellos navegadores que lo necesiten y durante el tiempo que lo necesiten.</p>
<p>Lo primero que tenemos que saber del plugin es que lo componen dos ficheros:</p>
<pre>fd-slider.js
fd-slider.css</pre>
<p>Utilizando el loader de <a href="http://www.manualweb.net/tutorial-modernizr/" title="Manual de Modernizr">Modernizr</a> veremos que quedaría de la siguiente forma:</p>
<pre class="javascript" style="font-family:monospace;">Modernizr.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	test<span style="color: #339933;">:</span>Modernizr.<span style="color: #660066;">inputtypes</span>.<span style="color: #660066;">range</span><span style="color: #339933;">,</span>
	nope<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'fd-slider.js'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'fd-slider.css'</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Vemos que la capacidad que validamos del <a href="http://www.manualweb.net/tutorial-html5/" title="Manual de HTML5">HTML5</a> es Modernizr.inputtypes.range.</p>
<p>Una vez cargados los ficheros del <a href="https://github.com/freqdec/fd-slider" title="Plugin fd-slider de jQuery">plugin fd-slider</a> tenemos que lanzar el siguiente código para inicializar el plugin:</p>
<pre class="javascript" style="font-family:monospace;">fdSlider.<span style="color: #660066;">onDomReady</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Así que insertaremos dicho código dentro del polyfill.</p>
<pre class="javascript" style="font-family:monospace;">Modernizr.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  test<span style="color: #339933;">:</span>Modernizr.<span style="color: #660066;">inputtypes</span>.<span style="color: #660066;">range</span><span style="color: #339933;">,</span>
  nope<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'fd-slider.js'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'fd-slider.css'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  complete<span style="color: #339933;">:</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>fdSlider<span style="color: #009900;">&#41;</span>fdSlider.<span style="color: #660066;">onDomReady</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><span style="color: #339933;">;</span></pre>
<p>Ya tendremos cargado nuestro slider con <a href="http://www.manualweb.net/tutorial-jquery/" title="Tutorial de jQuery">jQuery</a>funcionando en la página.</p>
<p>Os podéis descargar el <a href="https://github.com/freqdec/fd-slider" title="Plugin fd-slider de jQuery">plugin fd-slider</a> desde <a href="https://github.com/freqdec/fd-slider" title="Plugin fd-slider de jQuery">https://github.com/freqdec/fd-slider</a><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/javascript/como-utilizar-un-polyfill-con-modernizr/" rel="bookmark" title="Febrero 17, 2012">Como utilizar un Polyfill con Modernizr</a></li>
<li><a href="http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/" rel="bookmark" title="Febrero 16, 2012">Utilizar Placeholder con jQuery</a></li>
<li><a href="http://lineadecodigo.com/html5/controlar-volumen-de-video-html5-con-un-slider/" rel="bookmark" title="Febrero 3, 2012">Controlar volumen de vídeo HTML5 con un Slider</a></li>
<li><a href="http://lineadecodigo.com/html5/datalist-en-html5/" rel="bookmark" title="Febrero 1, 2012">DataList en HTML5</a></li>
<li><a href="http://lineadecodigo.com/html5/modificando-propiedades-css-con-un-slider/" rel="bookmark" title="Febrero 23, 2012">Modificando propiedades CSS con un Slider</a></li>
</ul>
<p><!-- Similar Posts took 6.028 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3865()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3865(){ jQuery(document).ready(function($) { $('.dd-google1-3865').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/crear-un-slider-con-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Utilizar Placeholder con jQuery</title>
		<link>http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 07:00:57 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[placeholder]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[ready]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3850</guid>
		<description><![CDATA[Seguro que alguno de vosotros ha leido nuestro artículo que cuenta como utilizar un placeholder con HTML5. Esto nos posibilita el poner un texto dentro de un campo de un formulario para orientar al usuario sobre que contenido insertar en dicho campo. Si bien, uno de los problemas que nos plantea el uso de ciertas [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3850'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Futilizar-placeholder-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/" data-count="horizontal" data-text="Utilizar Placeholder con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Seguro que alguno de vosotros ha leido nuestro <a href="http://lineadecodigo.com/html5/placeholder-marcadores-de-posicion-en-html5/" title="Cómo crear un placeholder con HTML5">artículo que cuenta como utilizar un placeholder con HTML5</a>. Esto nos posibilita el poner un texto dentro de un campo de un formulario para orientar al usuario sobre que contenido insertar en dicho campo.</p>
<p>Si bien, uno de los problemas que nos plantea el uso de ciertas propiedades <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a> es la falta de implementación por parte de ciertos navegadores. Es por ello que la experiencia del usuario de esos navegadores puede ser diferente a la del resto.</p>
<p>Si queremos utilizar <a href="http://www.w3api.com/wiki/HTML5:INPUT.placeholder" title="Atributo placeholder en HTML5">placeholders</a> sin <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a> podemos recurrir a un <a href="https://github.com/mathiasbynens/jquery-placeholder" title="Plugin jQuery para soporte de placeholders">plugin de jQuery</a>. Mediante el uso de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> y este plugin será muy sencillo poder utilizar un <a href="http://www.w3api.com/wiki/HTML5:INPUT.placeholder" title="Atributo placeholder en HTML5">placeholders</a>. Además es que la forma en la que utilicemos el <a href="http://www.w3api.com/wiki/HTML5:INPUT.placeholder" title="Atributo placeholder en HTML5">placeholders</a> será la misma forma en la que lo utilizábamos en <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a>.</p>
<p>Es decir, si queremos crear un <a href="http://www.w3api.com/wiki/HTML5:INPUT.placeholder" title="Atributo placeholder en HTML5">placeholders</a> pondremos lo siguiente:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;texto&quot;</span>&gt;</span>Nombre: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;texto&quot;</span> placeholder<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Inserte su nombre&quot;</span> <a href="http://w3api.com/wiki/HTML:size"><span style="color: #000066;">size</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre>
<p>Para poder utilizar el <a href="http://www.w3api.com/wiki/HTML5:INPUT.placeholder" title="Atributo placeholder en HTML5">placeholders</a> con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> tendremos que hacer varias cosas. La primera será instanciar <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> e instanciar el <a href="https://github.com/mathiasbynens/jquery-placeholder" title="Plugin jQuery para soporte de placeholders">plugin de jQuery</a>.</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SCRIPT"><span style="color: #000000; font-weight: bold;">script</span></a> <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SCRIPT"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SCRIPT"><span style="color: #000000; font-weight: bold;">script</span></a> <a href="http://w3api.com/wiki/HTML:src"><span style="color: #000066;">src</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.placeholder.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SCRIPT"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span></pre>
<p>Y el siguiente paso inicializar el <a href="https://github.com/mathiasbynens/jquery-placeholder" title="Plugin jQuery para soporte de placeholders">plugin de jQuery</a>. En este caso el código de incialización es:</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input, textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">placeholder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Si bien, deberemos de esperar a tener cargada la página. Por ello recurriremos al método <a href="http://www.w3api.com/wiki/jQuery:Ready()" title="Método ready de jQuery">ready()</a> de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.</p>
<pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<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;">'input, textarea'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">placeholder</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;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre>
<p>Con un <a href="https://github.com/mathiasbynens/jquery-placeholder" title="Plugin jQuery para soporte de placeholders">plugin de jQuery</a> y unas pocas líneas de código tenemos la capacidad de dar soporte a los placeholders de <a href="http://www.manualweb.net/tutorial-html5/" title="Tutorial de HTML5">HTML5</a>.</p>
<p>Te puedes descargar el  <a href="https://github.com/mathiasbynens/jquery-placeholder" title="Plugin jQuery para soporte de placeholders">plugin jQuery</a> desde <a href="https://github.com/mathiasbynens/jquery-placeholder" title="Plugin jQuery para placeholders">https://github.com/mathiasbynens/jquery-placeholder</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/javascript/como-utilizar-un-polyfill-con-modernizr/" rel="bookmark" title="Febrero 17, 2012">Como utilizar un Polyfill con Modernizr</a></li>
<li><a href="http://lineadecodigo.com/html5/placeholder-marcadores-de-posicion-en-html5/" rel="bookmark" title="Enero 12, 2011">PlaceHolder: Marcadores de posición en HTML5</a></li>
<li><a href="http://lineadecodigo.com/jquery/crear-un-slider-con-jquery/" rel="bookmark" title="Febrero 19, 2012">Crear un slider con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/" rel="bookmark" title="Octubre 11, 2011">Seleccionar un texto solo si no ha cambiado</a></li>
<li><a href="http://lineadecodigo.com/jquery/seleccionar-texto-al-posicionarse-en-un-campo/" rel="bookmark" title="Septiembre 23, 2011">Seleccionar texto al posicionarse en un campo</a></li>
</ul>
<p><!-- Similar Posts took 5.317 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3850()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3850(){ jQuery(document).ready(function($) { $('.dd-google1-3850').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Efecto leer más texto simplificado con jQuery</title>
		<link>http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 07:00:56 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[siblings]]></category>
		<category><![CDATA[span]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[toggle]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3652</guid>
		<description><![CDATA[El otro día veíamos como poder generar un efecto leer más texto con jQuery sobre un texto que no tenía estructura predefinida y que se encontraba dentro de un DIV. Hoy vamos a ver como simplificar este ejemplo si tenemos la estructura del texto predefinida. Con lo que nos quedará un efecto leer más texto [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3652'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fefecto-leer-mas-texto-simplificado-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/" data-count="horizontal" data-text="Efecto leer más texto simplificado con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>El otro día veíamos <a href="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/" title="Efecto leer más con jQuery">como poder generar un efecto leer más texto con jQuery</a> sobre un texto que no tenía estructura predefinida y que se encontraba dentro de un DIV.</p>
<p>Hoy vamos a ver como simplificar este ejemplo si tenemos la estructura del texto predefinida. Con lo que nos quedará un efecto leer más texto simplificado.</p>
<p>Y es que si podemos estructurar el texto sobre el que queremos realizar el efecto sería bueno que lo insertásemos en capas <a href="http://www.w3api.com/wiki/HTML:SPAN" title="Elemento SPAN de HTML">SPAN</a>. En concreto en tres capas <a href="http://www.w3api.com/wiki/HTML:SPAN" title="Elemento SPAN de HTML">SPAN</a>.</p>
<ul>
<li><strong>summary</strong>, con el texto de resumen.</li>
<li><strong>complete</strong>, con el resto del texto.</li>
<li><strong>more</strong>, con el texto "leer más".</li>
</ul>
<p>Es importante que utilicemos elementos <a href="http://www.w3api.com/wiki/HTML:SPAN" title="Elemento SPAN de HTML">SPAN</a> ya que estos son inline y se mostrarán todos seguidos, si saltos y darán uniformidad al texto.</p>
<p>La estructura quedará de la siguiente forma:</p>
<pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a> <a href="http://w3api.com/wiki/HTML:class"><span style="color: #000066;">class</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;summary&quot;</span>&gt;</span>
&nbsp;
Lorem ipsum dolor sit amet, vis alterum feugiat sanctus ea. Affert facete eu cum, ut dicta vitae quo. Cum id aeque option epicuri, nec oblique suscipit ad. Et sea odio adhuc altera. Verterem nominati an mel, his diam consetetur ei. Eligendi principes sed no, ubique patrioque vix cu, soluta veritus percipit vim ex.
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a> <a href="http://w3api.com/wiki/HTML:class"><span style="color: #000066;">class</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;complete&quot;</span>&gt;</span>
&nbsp;
Pro populo dolorem eu. Justo conclusionemque sea ne. At dicat putent eum. Reprimique delicatissimi vel et.
&nbsp;
Posse constituam pro eu. Sit graecis appetere at, id his quas possit platonem, ius at nobis decore ullamcorper. Vix ne latine iudicabit constituto, justo fastidii eleifend et pro, ei sit solet dicant mediocrem. Te sit cibo percipit persecuti. Debet convenire suavitate ei vis. Pri utinam labitur temporibus ex.
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a> <a href="http://w3api.com/wiki/HTML:class"><span style="color: #000066;">class</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;more&quot;</span>&gt;</span>Leer mas...<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span></pre>
<p>El código jQuery se quedará simplificado ya que solo tendremos que controlar el <a href="http://www.w3api.com/wiki/jQuery:Toggle%28%29" title="Método toggle de jQuery">.toggle()</a> sobre el elemento "more". Es decir, el cambio de estado de este elemento.</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:ready%28%29"><span style="color: #000066;">ready</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.more&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:toggle%28%29"><span style="color: #000066;">toggle</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:text"><span style="color: #000066;">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Leer menos...&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:siblings"><span style="color: #000066;">siblings</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.complete&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:show%28%29"><span style="color: #000066;">show</span></a><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: #339933;">,</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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:text"><span style="color: #000066;">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Leer mas...&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:siblings"><span style="color: #000066;">siblings</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.complete&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:hide%28%29"><span style="color: #000066;">hide</span></a><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;">&#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>
<p>En cada uno de los cambios de texto realizamos las tres acciones apoyadas en los métodos <a href="http://www.w3api.com/wiki/jQuery:Text%28%29" title="Método .text() de jQuery">.text()</a> para cambiar el texto del elemento "more", <a href="http://www.w3api.com/wiki/jQuery:Siblings%28%29" title="Método siblings de jQuery">.siblings()</a> para ir a por el elemento hermano "complete" y <a href="http://www.w3api.com/wiki/jQuery:Show%28%29" title="Método show de jQuery">.show()</a>/<a href="http://www.w3api.com/wiki/jQuery:Hide%28%29" title="Método Hide de jQuery">.hide()</a> para ocultar o mostrar el texto.</p>
<p>Vemos que con la estructuración predefinida de la página se nos simplifica mucho el código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> ya que nos evitamos la reestructuración del contenido "al vuelo" con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/" rel="bookmark" title="Enero 4, 2012">Efecto leer más texto con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-slide-con-jquery/" rel="bookmark" title="Enero 5, 2012">Efecto slide con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/usando-cookies-con-jquery/" rel="bookmark" title="Diciembre 28, 2009">Usando cookies con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/ocultar-y-mostrar-elementos-con-jquery/" rel="bookmark" title="Febrero 5, 2009">Ocultar y mostrar elementos con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-fade-en-jquery/" rel="bookmark" title="Marzo 30, 2012">Efecto Fade en jQuery</a></li>
</ul>
<p><!-- Similar Posts took 5.337 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3652()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3652(){ jQuery(document).ready(function($) { $('.dd-google1-3652').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Efecto slide con jQuery</title>
		<link>http://lineadecodigo.com/jquery/efecto-slide-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/efecto-slide-con-jquery/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 18:52:00 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[efecto]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[slide]]></category>
		<category><![CDATA[toggle]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3657</guid>
		<description><![CDATA[El efecto slide es el que nos permite realizar un desplazamiento de un elemento en alguna dirección (izquierda, derecha, arriba o abajo). En las siguientes líneas veremos lo sencillo que es hacerlo con jQuery. En nuestro ejemplo vamos a desplazar una capa que tengamos en la página, para ocultarla. De esta manera aplicaremos el efecto [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3657'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/efecto-slide-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fefecto-slide-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/efecto-slide-con-jquery/" data-count="horizontal" data-text="Efecto slide con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>El efecto slide es el que nos permite realizar un desplazamiento de un elemento en alguna dirección (izquierda, derecha, arriba o abajo). En las siguientes líneas veremos lo sencillo que es hacerlo con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.</p>
<p>En nuestro ejemplo vamos a desplazar una capa que tengamos en la página, para ocultarla. De esta manera aplicaremos el efecto slide en ese momento.</p>
<p>Lo primero que tenemos que saber es que la función que oculta un elemento en <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> es <a href="http://www.w3api.com/wiki/jQuery:Hide%28%29" title="Efecto hide en jQuery">.hide()</a>. Pero si vemos la sintaxis (la más común) de esta función:</p>
<pre class="jquery" style="font-family:monospace;">.<a href="http://w3api.com/wiki/jQuery:hide%28%29"><span style="color: #000066;">hide</span></a><span style="color: #009900;">&#40;</span>velocidad<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>funcion_callback<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></pre>
<p>Nos damos cuenta que solo podemos aplicar una velocidad de ocultación y una función de callback para ejecutar cuando se termine la ocultación. Entonces, ¿dónde ejecuto el efecto?</p>
<p>Para ello tenemos la librería <a href="http://www.w3api.com/wiki/Categor%C3%ADa:JQuery_UI" title="Librería jQuery UI">jQuery UI</a>, que es una extensión al core de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>, dotándole de capacidades gráficas como la de los efectos.</p>
<p>Así en <a href="http://www.w3api.com/wiki/Categor%C3%ADa:JQuery_UI" title="Librería jQuery UI">jQuery UI</a> encontraremos una extensión de la función <a href="http://www.w3api.com/wiki/jQuery:Hide%28%29" title="Efecto hide en jQuery">.hide()</a> para que podamos aplicar efectos. Lo mismo sucede con las funciones <a href="http://www.w3api.com/wiki/jQuery:Show()" title="Efecto Show de jQuery">.show()</a> y <a href="http://www.w3api.com/wiki/jQuery:Toggle()" title="Efecto Toggle de jQuery">.toggle()</a>. De esta manera la función <a href="http://www.w3api.com/wiki/jQuery:Hide%28%29" title="Efecto hide en jQuery">.hide()</a> podrá recibir un efecto como parámetro.</p>
<p>El efecto se compondrá de dos partes:</p>
<ul>
<li>Nombre del efecto</li>
<li>Parámetros del efecto</li>
</ul>
<p>En el caso del <a href="http://www.w3api.com/wiki/jQuery:Slide" title="Efecto Slide de jQuery UI">efecto slide</a> podemos indicar como parámetros la dirección (izquierda, arriba,...), distancia (punto del elemento en el que se aplicará el efecto) y el modo (si es show o hide).</p>
<p>De esa manera nuestro efecto saliendo hacía la izquierda sería algo así:</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:hide%28%29"><span style="color: #000066;">hide</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slide&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> direction<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;left&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Dónde this será el elemento sobre el que aplicamos el efecto. Por ejemplo, si queremos desplazar una capa:</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;micapa&quot;</span> <a href="http://w3api.com/wiki/HTML:style"><span style="color: #000066;">style</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;background-color:red;width:100px;height:100px&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
&nbsp;</pre>
<p>El código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> nos quedará de la siguiente forma:</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:ready%28%29"><span style="color: #000066;">ready</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#micapa&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:click%28%29"><span style="color: #000066;">click</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:hide%28%29"><span style="color: #000066;">hide</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slide&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> direction<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;left&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</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></pre>
<p>Hemos utilizado el método <a href="http://www.w3api.com/wiki/jQuery:Click()" title="Funcion Click de jQuery">.click()</a> para lanzar el efecto cuando se pulse sobre la capa.</p>
<p>Con esos sencillos pasos tenemos completado el efecto slide con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/usando-cookies-con-jquery/" rel="bookmark" title="Diciembre 28, 2009">Usando cookies con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/ocultar-y-mostrar-elementos-con-jquery/" rel="bookmark" title="Febrero 5, 2009">Ocultar y mostrar elementos con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/" rel="bookmark" title="Enero 6, 2012">Efecto leer más texto simplificado con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/" rel="bookmark" title="Enero 4, 2012">Efecto leer más texto con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/filtrar-elementos-de-un-array-con-jquery/" rel="bookmark" title="Abril 4, 2011">Filtrar elementos de un array con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 5.000 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3657()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3657(){ jQuery(document).ready(function($) { $('.dd-google1-3657').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/efecto-slide-con-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Efecto leer más texto con jQuery</title>
		<link>http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 07:00:08 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[ready]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[siblings]]></category>
		<category><![CDATA[span]]></category>
		<category><![CDATA[substr]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[toggle]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3638</guid>
		<description><![CDATA[En el ejemplo de hoy vamos a ver como podemos codificar el efecto leer más texto con jQuery. La idea es tener un texto, del cual solo mostraremos su contenido inicial y un enlace que indique "leer más". Al pulsar sobre el enlace "leer más" se producirá el efecto leer más texto que consiste en [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3638'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fefecto-leer-mas-texto-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/" data-count="horizontal" data-text="Efecto leer más texto con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>En el ejemplo de hoy vamos a ver como podemos codificar el efecto leer más texto con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>. La idea es tener un texto, del cual solo mostraremos su contenido inicial y un enlace que indique "leer más". Al pulsar sobre el enlace "leer más" se producirá el efecto leer más texto que consiste en mostrar el contenido completo del texto.</p>
<p>Seguro que habéis visto el efecto leer más texto en muchas web, como por ejemplo en los comentarios de <a href="http://www.youtube.com" title="Youtube">YouTube</a>.</p>
<p>Lo primero será poner el texto en nuestra página. El texto será completo y se encontrará dentro de una capa <a href="http://www.w3api.com/wiki/HTML:DIV" title="Elemento DIV de HTML">DIV</a>.</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a> <a href="http://w3api.com/wiki/HTML:class"><span style="color: #000066;">class</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comentario&quot;</span>&gt;</span>
	Lorem ipsum dolor sit amet, vis alterum feugiat sanctus ea. Affert facete eu cum, ut dicta vitae quo. Cum id aeque option epicuri, nec oblique suscipit ad. Et sea odio adhuc altera. Verterem nominati an mel, his diam consetetur ei. Eligendi principes sed no, ubique patrioque vix cu, soluta veritus percipit vim ex.<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a>&gt;</span>
	Pro populo dolorem eu. Justo conclusionemque sea ne. At dicat putent eum. Reprimique delicatissimi vel et.<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a>&gt;</span>
	Posse constituam pro eu. Sit graecis appetere at, id his quas possit platonem, ius at nobis decore ullamcorper. Vix ne latine iudicabit constituto, justo fastidii eleifend et pro, ei sit solet dicant mediocrem. Te sit cibo percipit persecuti. Debet convenire suavitate ei vis. Pri utinam labitur temporibus ex.
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
&nbsp;</pre>
<p>Siempre que utilicemos <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> es bueno el utilizar clases o indicadores para acceder a los elementos. En este caso hemos utilizado el <a href="http://www.w3api.com/wiki/HTML:Id" title="Atributo id de HTML">id</a> "comentario" para identificar claramente nuestro texto.</p>
<p>Ahora ya vamos con nuestro código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>, el cual colocaremos en la cabecera de nuestra página dentro del método <a href="http://www.w3api.com/wiki/jQuery:Ready%28%29" title="Método ready de jQuery">.ready()</a>.</p>
<blockquote><p>Acordaros que el método <a href="http://www.w3api.com/wiki/jQuery:Ready%28%29" title="Método ready de jQuery">.ready()</a> se ejecuta una vez que se ha cargado toda la página, asegurando así la consistencia de nuestro código a la hora de acceder a los elementos.</p></blockquote>
<p>Lo primero que hacemos es establecer el número de caracteres que se previsualizarán y extraeremos la subcadena que representan del contenido del texto. El contenido nos lo dará el método <a href="http://www.w3api.com/wiki/jQuery:Html%28%29" title="Método html de jQuery">.html()</a> sobre la capa "comentario" y la subcadena la conseguimos mediante el método <a href="http://www.manualweb.net/tutorial-javascript/" title="Manual de JavaScript">Javascript</a> <a href="http://www.w3api.com/wiki/Javascript:String.substr%28%29" title="Método substr de Javascript">.substr()</a>.</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> caracteresAMostrar <span style="color: #339933;">=</span> <span style="color: #CC0000;">300</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> contenido <span style="color: #339933;">=</span> <span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.comentario&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:html"><span style="color: #000066;">html</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>contenido.<a href="http://w3api.com/wiki/jQuery:length"><span style="color: #000066;">length</span></a> <span style="color: #339933;">&gt;</span> caracteresAMostrar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> resumen <span style="color: #339933;">=</span> contenido.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> caracteresAMostrar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> todo <span style="color: #339933;">=</span> contenido.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span>caracteresAMostrar<span style="color: #339933;">,</span> contenido.<a href="http://w3api.com/wiki/jQuery:length"><span style="color: #000066;">length</span></a> <span style="color: #339933;">-</span> caracteresAMostrar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>En la variable resumen dejamos el resumen de texto a mostrar, mientras que en la variable todo dejamos el resto del contenido.</p>
<p>Ahora, con estos textos vamos a modificar la estructura de la página (si nos hubiesen dado esta estructura previa nos ahorraríamos estos pasos, pero hemos preferido partir de un texto completo).</p>
<p>En la nueva estructuración crearemos dentro del <a href="http://www.w3api.com/wiki/HTML:DIV" title="Elemento DIV de HTML">DIV</a> el texto, un <a href="http://www.w3api.com/wiki/HTML:SPAN" title="Elemento span de HTML">SPAN</a> donde tendremos el resto del texto y otro <a href="http://www.w3api.com/wiki/HTML:SPAN" title="Elemento span de HTML">SPAN</a> con la frase Leer Más. Luego veremos que este texto lo modificamos dependiendo de si hay que "Leer más o leer menos".</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> nuevocontenido <span style="color: #339933;">=</span> resumen <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;span class=&quot;complete&quot;&gt;'</span> <span style="color: #339933;">+</span> todo <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;more&quot;&gt;Leer mas...&lt;/span&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.comentario&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:html"><span style="color: #000066;">html</span></a><span style="color: #009900;">&#40;</span>nuevocontenido<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>El código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> de esta parte queda de la siguiente forma:</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> caracteresAMostrar <span style="color: #339933;">=</span> <span style="color: #CC0000;">300</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> contenido <span style="color: #339933;">=</span> <span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.comentario&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:html"><span style="color: #000066;">html</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>contenido.<a href="http://w3api.com/wiki/jQuery:length"><span style="color: #000066;">length</span></a> <span style="color: #339933;">&gt;</span> caracteresAMostrar<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> resumen <span style="color: #339933;">=</span> contenido.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> caracteresAMostrar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> todo <span style="color: #339933;">=</span> contenido.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span>caracteresAMostrar<span style="color: #339933;">,</span> contenido.<a href="http://w3api.com/wiki/jQuery:length"><span style="color: #000066;">length</span></a> <span style="color: #339933;">-</span> caracteresAMostrar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> nuevocontenido <span style="color: #339933;">=</span> resumen <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;span class=&quot;complete&quot;&gt;'</span> <span style="color: #339933;">+</span> todo <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;more&quot;&gt;Leer mas...&lt;/span&gt;'</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.comentario&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:html"><span style="color: #000066;">html</span></a><span style="color: #009900;">&#40;</span>nuevocontenido<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>Ahora tenemos que codificar el efecto leer más texto en <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>. Y este paso es sencillo. Ya que si pinchamos sobre "leer más" habrá que hacer visible la parte definida como "more" y poner un texto "leer menos". Y si pulsamos sobre "leer menos" realizaremos el efecto contrario, que será esconder "more" y poner el texto "leer más".</p>
<p>Como estamos hablando de un cambio de estado de un elemento. De nuestro elemento "more". Lo que haremos será apoyarnos en el método <a href="http://www.w3api.com/wiki/jQuery:Toggle%28%29" title="Función toggle de jQuery">.toggle()</a>, el cual efectua una acción u otra cada vez que pulsemos sobre el elemento.</p>
<p>El código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> quedará de la siguiente forma:</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.more&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:toggle%28%29"><span style="color: #000066;">toggle</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:text"><span style="color: #000066;">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Leer menos...&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:siblings"><span style="color: #000066;">siblings</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.complete&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:show%28%29"><span style="color: #000066;">show</span></a><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: #339933;">,</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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:text"><span style="color: #000066;">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Leer mas...&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:siblings"><span style="color: #000066;">siblings</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.complete&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:hide%28%29"><span style="color: #000066;">hide</span></a><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;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Vemos que utilizamos varios métodos de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>:</p>
<ul>
<li><strong><a href="http://www.w3api.com/wiki/jQuery:Text%28%29" title="Función text de jQuery">.text()</a></strong>, nos permite cambiar el texto del elemento por "leer menos" o "leer más".</li>
<li><strong><a href="http://www.w3api.com/wiki/jQuery:Siblings%28%29" title="Función siblings de jQuery">.siblings()</a></strong>, nos permite acceder a los elementos que está en nuestra misma estructura del DOM, el id se lo pasamos por parámetro.</li>
<li><strong><a href="http://www.w3api.com/wiki/jQuery:Show%28%29" title="Función show de jQuery">.show()</a></strong>, muestra el contenido del elemento.</li>
<li><strong><a href="http://www.w3api.com/wiki/jQuery:Hide%28%29" title="Función Hide de jQuery">.hide()</a></strong>, oculta el contenido del elemento.</li>
</ul>
<p>Con esto ya tenemos todo nuestro código <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a> y el efecto leer más texto conseguido.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/efecto-leer-mas-texto-simplificado-con-jquery/" rel="bookmark" title="Enero 6, 2012">Efecto leer más texto simplificado con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/volcar-el-contenido-de-un-array-con-jquery/" rel="bookmark" title="Mayo 31, 2011">Volcar el contenido de un array con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/modificar-el-contenido-de-una-capa-con-jquery/" rel="bookmark" title="Mayo 27, 2010">Modificar el contenido de una capa con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-slide-con-jquery/" rel="bookmark" title="Enero 5, 2012">Efecto slide con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/efecto-fade-en-jquery/" rel="bookmark" title="Marzo 30, 2012">Efecto Fade en jQuery</a></li>
</ul>
<p><!-- Similar Posts took 5.133 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3638()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3638(){ jQuery(document).ready(function($) { $('.dd-google1-3638').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/efecto-leer-mas-texto-con-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Seleccionar un texto solo si no ha cambiado</title>
		<link>http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/</link>
		<comments>http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 06:00:48 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[defaultValue]]></category>
		<category><![CDATA[focus]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[textarea]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3559</guid>
		<description><![CDATA[Unos cuantos han sido los artículos que le hemos dedicado a la selección de texto con jQuery: Seleccionar el texto de un campo, Seleccionar el texto al posicionarse en un campo y Detectar el texto seleccionado con jQuery. Pero no quería dejar de escribir uno que nos va a dar un buen efecto visual y [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3559'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Fseleccionar-un-texto-solo-si-no-ha-cambiado%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/" data-count="horizontal" data-text="Seleccionar un texto solo si no ha cambiado" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Unos cuantos han sido los artículos que le hemos dedicado a la selección de texto con jQuery: <a href="http://lineadecodigo.com/jquery/seleccionar-el-texto-de-un-campo/" title="Seleccionar el texto de un campo con jQuery">Seleccionar el texto de un campo</a>, <a href="http://lineadecodigo.com/jquery/seleccionar-texto-al-posicionarse-en-un-campo/" title="Seleccionar texto al posicionarse en un campo con jQuery">Seleccionar el texto al posicionarse en un campo</a> y <a href="http://lineadecodigo.com/jquery/detectar-texto-seleccionado-con-jquery/" title="Detectar el texto seleccionado con jQuery">Detectar el texto seleccionado con jQuery</a>. Pero no quería dejar de escribir uno que nos va a dar un buen efecto visual y este consiste en seleccionar un texto solo si este no ha cambiado con <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>.</p>
<p>Es decir, seleccionaremos el texto del campo si sigue siendo el mismo que al cargar la página. Si el usuario ha cambiado el contenido, ya no lo seleccionaremos.</p>
<p>Manos a la obra... Lo primero el formulario al uso (casi que ya lo imaginas).</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;miform&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;texto&quot;</span>&gt;</span>Inserta texto:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;texto&quot;</span> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Texto por defecto&quot;</span> <a href="http://w3api.com/wiki/HTML:size"><span style="color: #000066;">size</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;areatexto&quot;</span>&gt;</span>Cada vez que pinches en el <span style="color: #ddbb00;">&amp;aacute;</span>rea de texto se selecionará. Esto sucederá mientras no cambies el contenido original del mismo.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:TEXTAREA"><span style="color: #000000; font-weight: bold;">textarea</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;areatexto&quot;</span> <a href="http://w3api.com/wiki/HTML:cols"><span style="color: #000066;">cols</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;25&quot;</span> <a href="http://w3api.com/wiki/HTML:rows"><span style="color: #000066;">rows</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;8&quot;</span>&gt;</span>Texto por defecto<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:TEXTAREA"><span style="color: #000000; font-weight: bold;">textarea</span></a>&gt;&lt;<a href="http://w3api.com/wiki/HTML:BR"><span style="color: #000000; font-weight: bold;">br</span></a><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;</pre>
<p>Hay que fijarse bien que hemos puesto los campos <a href="http://www.w3api.com/wiki/HTML:INPUT" title="elemento input de HTML">input</a> y <a href="http://www.w3api.com/wiki/HTML:TEXTAREA" title="elemento textarea de HTML">textarea</a> con textos por defecto.</p>
<p>Será cuándo el usuario acceda al campo cuando comprobaremos si ha cambiado el texto. Para ello utilizamos el método <a href="http://www.w3api.com/wiki/jQuery:Focus%28%29" title="metodo focus de jQuery">.focus()</a> de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual de jQuery">jQuery</a>. En este caso vamos a ver cómo sería para el <a href="http://www.w3api.com/wiki/HTML:TEXTAREA" title="elemento textarea de HTML">textarea</a>.</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:ready%28%29"><span style="color: #000066;">ready</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;textarea&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:focus%28%29"><span style="color: #000066;">focus</span></a><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;">&#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>
<p>Ahora tenemos que diferenciar como conseguir el texto que tiene actualmente y el texto que estaba por defecto. El texto actual lo conseguiremos con .value y el texto por defecto con .defaultValue.</p>
<p>Así que seleccionaremos el texto, es decir, lamaremos al método <a href="http://www.w3api.com/wiki/jQuery:Select%28%29" title="método select de jQuery">.select()</a> si son iguales.</p>
<pre class="jquery" style="font-family:monospace;"><span style="color: #000066;">$</span><span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:ready%28%29"><span style="color: #000066;">ready</span></a><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;">$</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;textarea&quot;</span><span style="color: #009900;">&#41;</span>.<a href="http://w3api.com/wiki/jQuery:focus%28%29"><span style="color: #000066;">focus</span></a><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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">defaultValue</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<a href="http://w3api.com/wiki/jQuery:select%28%29"><span style="color: #000066;">select</span></a><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><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Así ya hemos seleccionado el texto solo si este no ha cambiado.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/seleccionar-texto-al-posicionarse-en-un-campo/" rel="bookmark" title="Septiembre 23, 2011">Seleccionar texto al posicionarse en un campo</a></li>
<li><a href="http://lineadecodigo.com/jquery/detectar-texto-seleccionado-con-jquery/" rel="bookmark" title="Septiembre 20, 2011">Detectar texto seleccionado con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/seleccionar-el-texto-de-un-campo/" rel="bookmark" title="Septiembre 21, 2011">Seleccionar el texto de un campo</a></li>
<li><a href="http://lineadecodigo.com/jquery/utilizar-placeholder-con-jquery/" rel="bookmark" title="Febrero 16, 2012">Utilizar Placeholder con jQuery</a></li>
<li><a href="http://lineadecodigo.com/jquery/cambios-en-un-combo-con-jquery/" rel="bookmark" title="Mayo 17, 2011">Cambios en un combo con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 6.018 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3559()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3559(){ jQuery(document).ready(function($) { $('.dd-google1-3559').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/seleccionar-un-texto-solo-si-no-ha-cambiado/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Listar opciones seleccionadas de un combo con jQuery</title>
		<link>http://lineadecodigo.com/jquery/listar-opciones-seleccionadas-de-un-combo-con-jquery/</link>
		<comments>http://lineadecodigo.com/jquery/listar-opciones-seleccionadas-de-un-combo-con-jquery/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 06:00:09 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[Combo]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[formularios]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[OPTION]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[selected]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=3491</guid>
		<description><![CDATA[jQuery nos permite manejar de forma muy sencilla los formularios con un amplio conjunto de métodos. En este caso vamos a ver cómo podemos acceder a la lista de opciones seleccionadas de un combo y mostrarlas por pantalla utilizando la librería jQuery. En primer lugar vamos a pintar el combo (esta vez va de fútbol): [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-3491'></div><g:plusone size='medium' href='http://lineadecodigo.com/jquery/listar-opciones-seleccionadas-de-un-combo-con-jquery/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fjquery%2Flistar-opciones-seleccionadas-de-un-combo-con-jquery%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/jquery/listar-opciones-seleccionadas-de-un-combo-con-jquery/" data-count="horizontal" data-text="Listar opciones seleccionadas de un combo con jQuery" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>jQuery nos permite <a href="http://www.w3api.com/wiki/Categor%C3%ADa:JQuery_Forms" title="funciones jQuery para el manejo de Formularios">manejar de forma muy sencilla los formularios con un amplio conjunto de métodos</a>. En este caso vamos a ver cómo podemos acceder a la lista de opciones seleccionadas de un combo y mostrarlas por pantalla utilizando la librería <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual sobre la librería jQuery">jQuery</a>.</p>
<p>En primer lugar vamos a pintar el combo (esta vez va de fútbol):</p>
<pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myform&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SELECT"><span style="color: #000000; font-weight: bold;">select</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;equipos&quot;</span> <a href="http://w3api.com/wiki/HTML:multiple"><span style="color: #000066;">multiple</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multiple&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;barça&quot;</span> <a href="http://w3api.com/wiki/HTML:selected"><span style="color: #000066;">selected</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;selected&quot;</span>&gt;</span>Barça<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;real madrid&quot;</span>&gt;</span>Real Madrid<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;atletico madrid&quot;</span>&gt;</span>Atl<span style="color: #ddbb00;">&amp;eacute;</span>tico Madrid<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;valencia&quot;</span>&gt;</span>Valencia CF<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;betis&quot;</span> <a href="http://w3api.com/wiki/HTML:selected"><span style="color: #000066;">selected</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;selected&quot;</span>&gt;</span>Real Betis<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;deportivo&quot;</span>&gt;</span>Deportivo de la Coruña<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:OPTION"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SELECT"><span style="color: #000000; font-weight: bold;">select</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;</pre>
<p>Si queremos que puedan existir varias opciones seleccionadas dentro del combo deberemos de utilizar el atributo  <a href="http://www.w3api.com/wiki/HTML:Multiple" title="atributo multiple de HTML">multiple="multiple"</a> dentro del <a href="http://www.w3api.com/wiki/HTML:SELECT" title="elemento HTML select">select</a>. De igual manera, si queremos prefijar una de las opciones deberemos de utilizar el atributo <a href="http://www.w3api.com/wiki/HTML:Selected" title="atributo HTML selected">selected="selected"</a>.</p>
<p>Listaremos las opciones seleccionadas del combo cada vez que haya un cambio en dicho combo. Para ello vamos a manejar el método <a href="http://www.w3api.com/wiki/jQuery:Change()" title="método change de jQuery">.change()</a> de <a href="http://www.manualweb.net/tutorial-jquery/" title="Manual sobre la librería jQuery">jQuery</a>. En cada cambio ejecutaremos la función que le digamos al método <a href="http://www.w3api.com/wiki/jQuery:Change()" title="método change de jQuery">.change()</a>.</p>
<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;">&quot;#equipos&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</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;">&#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>
<p>Y ¿qué va a hacer nuestra función? Pues recorrer el elemento <a href="http://www.w3api.com/wiki/HTML:SELECT" title="elemento HTML select">select</a>. Pero no todo el elemento <a href="http://www.w3api.com/wiki/HTML:SELECT" title="elemento HTML select">select</a>, si no aquellas opciones que estén seleccionadas. Así que vamos a utilizar un selector. El selector será:</p>
<pre>#equipos option:selected</pre>
<p>Es decir, del combo o <a href="http://www.w3api.com/wiki/HTML:SELECT" title="elemento HTML select">select</a> 'equipos' elige aquellas opciones, u <a href="http://www.w3api.com/wiki/HTML:OPTION" title="elemento option de HTML">option</a>, que estén seleccionadas, es decir <a href="http://www.w3api.com/wiki/HTML:Selected" title="atributo selected de HTML">'selected'</a>.</p>
<p>Ahora, de cada opción obtendremos su valor mediante el método <a href="http://www.w3api.com/wiki/jQuery:Text%28%29" title="método jQuery text">.text()</a></p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#equipos option:selected&quot;</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>
  texto <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;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; - &quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Ya solo nos quedará volcar el contenido en alguna capa de nuestra página. Para ello creamos un elemento <a href="http://www.w3api.com/wiki/HTML:DIV" title="elemento DIV de HTML">DIV</a> al que llamaremos 'resultado' y al que volcaremos los datos mediante:</p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#resultado&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>texto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>Solo nos queda un pequeño detalle. Y es que si hemos puesto campos seleccionados de antemano, si queremos que se ejecute nuestro método <a href="http://www.w3api.com/wiki/jQuery:Change()" title="método change de jQuery">.change()</a>, podemos simular el ejecutarlo mediante el método <a href="http://www.w3api.com/wiki/jQuery:Trigger%28%29" title="Método jQuery trigger">.trigger()</a></p>
<pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#equipos&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'change'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
<p>De esta manera tendremos la primera ejecución del <a href="http://www.w3api.com/wiki/jQuery:Change()" title="método change de jQuery">.change()</a>. El código entero nos quedará de la siguiente forma:</p>
<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;">&quot;#equipos&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</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: #003366; font-weight: bold;">var</span> texto <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Opciones Seleccionadas: &quot;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#equipos option:selected&quot;</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>
      texto <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;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; - &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#resultado&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>texto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'change'</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>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/cambios-en-un-combo-con-jquery/" rel="bookmark" title="Mayo 17, 2011">Cambios en un combo con jQuery</a></li>
<li><a href="http://lineadecodigo.com/html/predeterminar-valor-en-un-combo/" rel="bookmark" title="Noviembre 16, 2006">Predeterminar valor en un combo</a></li>
<li><a href="http://lineadecodigo.com/html/combos-de-seleccion/" rel="bookmark" title="Noviembre 2, 2006">Combos de selección</a></li>
<li><a href="http://lineadecodigo.com/javascript/activar-valores-de-un-combo-dinamicamente/" rel="bookmark" title="Septiembre 16, 2009">Activar valores de un combo dinámicamente</a></li>
<li><a href="http://lineadecodigo.com/jquery/detectar-texto-seleccionado-con-jquery/" rel="bookmark" title="Septiembre 20, 2011">Detectar texto seleccionado con jQuery</a></li>
</ul>
<p><!-- Similar Posts took 10.267 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_3491()',1000); }); </script><script type="text/javascript"> function loadGoogle1_3491(){ jQuery(document).ready(function($) { $('.dd-google1-3491').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/jquery/listar-opciones-seleccionadas-de-un-combo-con-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: lineadecodigo.com @ 2012-05-23 13:26:40 by W3 Total Cache -->
