Need to make image id instated of the number \[code\]var number = $(this).attr('rel'); number = parseInt(number); $('#carousel .slides li:nth-child(' + (number + 1) + ')').click(); $('#carousel').flexslider({\[/code\]I mean replace number = parseInt(number); to id of image Text \[code\]<article class="col img_prev2"> <img src="http://stackoverflow.com/questions/15848053/img/slideshow/slideshow2.jpg" alt="#img2" rel="1" class="thumb_main_page"> <h5>Text</h5></article>\[/code\]On Above the rel attribute start from 0 ( rel="0" ) so i need to make it for example slideshow1.jpg instated "0" .