indexing - Jquery Clone function with eq(index) -


i have many similar divs id's tictab ..and want make first tictab unvisible , add clone of @ end. using following code

$('#leftbutton').click(function(){           $('#tictab').clone().insertbefore('#rightbutton');      $('#tickers').find('#tictab').eq(ind).css('display','none');      ind++;   }); 

where ind starts 0. problem facing here jquery making cloned tictabs invisible reason...i'm guessing because of issue in indexing of eq() function. can please tell me right way it.

you cannot have multiple element same id. if need type of relationship between them all, use common class name, not common id name. id attribute meant unique value not found on other element in document.

it sounds though want clone latest .tictab element, hide it, insert before #rightbutton, , show previous hidden clone. if that's case, following work:

$("#leftbutton").on("click", function(){     $(".tictab:last").show().clone().hide().insertbefore("#rightbutton"); });​ 

fiddle: http://jsfiddle.net/jonathansampson/dpze5/


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -