Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery question
    primarykey
    data
    text
    <p>I am using jquery so that when the user clicks a link I get the id of said link then use it to select a li item with the same id and animate it. Well, at least that's what I'm trying to do...so far I have:</p> <pre><code>$(function(){ $('#slider-buttons a').click(function(){ var x = $(this).attr('id'); var y = $('#slider-stage-list li' + x); if(x == "inicio") $(this).animate({ "left" : "0px"},700); else $(this).animate({ "left" : (increment*3) + "px"},700); }); }); </code></pre> <p>I've tried various combinations but I still can't get 'y' to have the value of the list item with the same id as x (the clicked url)...x does gets the correct id but y still returns "undefined" at best...here's the html code that goes along...</p> <pre><code>&lt;div id="slider-buttons"&gt; &lt;a href="#" id="inicio"&gt;Inicio&lt;/a&gt; &lt;br /&gt; &lt;a href="#" id="previous"&gt;&amp;iquest;Qui&amp;eacute;nes Somos?&lt;/a&gt; &lt;br /&gt; &lt;a href="#" id="clases"&gt;Clases&lt;/a&gt; &lt;br /&gt; &lt;a href="#" id="equipo"&gt;Equipo&lt;/a&gt; &lt;br /&gt; &lt;a href="#" id="album"&gt;&amp;Aacute;lbum&lt;/a&gt; &lt;br /&gt; &lt;a href="#" id="especiales"&gt;Eventos Especiales&lt;/a&gt; &lt;br /&gt; &lt;a href="#" id="#"&gt;Cont&amp;aacute;ctanos&lt;/a&gt; &lt;br /&gt; &lt;/div&gt; &lt;div id="stage"&gt; &lt;ul id="slider-stage-list"&gt; &lt;li id="inicio"&gt;Inicio&lt;/li&gt; &lt;li id="nos"&gt;&amp;iquest;Qui&amp;eacute;nes Somos?&lt;/li&gt; &lt;li id="clases"&gt;Clases&lt;/li&gt; &lt;li id="equipo"&gt;Equipo&lt;/li&gt; &lt;li id="album"&gt;&amp;Aacute;lbum&lt;/li&gt; &lt;li id="especiales"&gt;Eventos Especiales&lt;/li&gt; &lt;li id="#"&gt;Cont&amp;aacute;ctanos&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>any help will be appreciated =)</p> <hr> <p><strong>Edit to answer the 3 responses</strong></p> <p>If I do any of those I get in console.log(); "[object Object]" =/</p> <hr> <p><strong>Edit answering BC</strong></p> <p>Thanks for the HTML correction, still if I write down the code you gave me for jquery I still get in console.log(); "[object Object]"</p> <hr> <p><strong>Edit 'cause I didn't got the last response</strong></p> <p>If I try that approach I either get "[object Object]" or nothing...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload