Just so you know, you cannot have two elements on the same page with
the same id. You can have the same class though.

<img src="..." id="one" class="myImg" />
<img src="..." id="two" class="myImg" />

<div id="div_one">...</div>
<div id="div_two">...</div>

$(function() {
     $(".myImg").click(function() {
          var imgID = $(this).attr('id');
          $("#div_"+imgID).slideUp();
     });
});

On Mar 5, 1:32 pm, whoisonfirst <bp.ly...@gmail.com> wrote:
> I have a list of several thumbnails. On click thumbnail I'd like to slide up
> a div elsewhere on the page that has an id of the same name as the image id.
>
> The first div (one) is shown as default. The other divs are hidden untill a
> thumbnail is clicked. Then the div with the same id as thumbnail slides up
> and shows and the first one is hidden and so on.
>
> See example html below.
>
> Jquery code so far
>
> $(document).ready(function(){
>
>         //hide the all div except first one
>         $('.slierwrap:not(:first)').hide();
>
>         //when the anchor is clicked content gets slided
>         $("#section1").click(function(event) {
>         var element = $(this);
>
>        $('.sliderwrap').slideUp("slow");
>
>      this is where I'm stuck. Im not sure how to go about getting  the img
> id  and assigning to element (this)   to get the div with same name as img
> id to slide.
>
> Help please.
>
> <div id ="section1">
> <ul>
> <li> largeimagepath  thumbnailpath  </li>
>
> <li> largeimagepath  thumbnailpath  </li>
> </ul>
> </div>
>
> <div id = "sliderwrap">
> <div id ="one">some text</div>
> <div id ="two">some text</div>
> </div>
> --
> View this message in 
> context:http://www.nabble.com/get-img-id-and-slide-up-div-with-same-name-tp22...
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to