Pregunta

i want to get the url for the image. For this i use this code

 $(function () {
     $('.li').mousedown(function (e) {
         if (e.which === 1) {
             $(".li:nth-child(n) a").attr('id');
             var clickId = this.id;
             var n = clickId - 1;
             var imageurl = $(".fadein img:eq(" + n + ")").attr("src");
             alert(imageurl);
         }
     });
 });

problem is next. slide show displays a second image. I click on the first position and i'm getting the current url of image which is displayed. How to get the url of first image ?

who knows!!!!!! why i don't get an url of the image by id?

¿Fue útil?

Solución

try something like this:

$(function () {
 $('.circle li').on('click',function (e) {
         var id = $(this).attr("id"); //this is the number of id
         var elem = $(this).attr("id") -1; //this is modified id to table elements
     var imageurl = $('.fadein img:eq('+elem+')').attr('src');
     alert( 'the no. '+id +' have url ' + imageurl);

 });
});

here is the example http://jsfiddle.net/CzmTA/3/

and remember the position of element in jquery is an array and it starts from 0 not 1 i think this should work

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top