mardi 17 novembre 2015

Jquery click not working as expected

I have a wordpress site.

I add custom thumbnails in product section, it shows vertically. I just add the jquery code following:

$(document).ready(function(){
$('.active-thumb-link a').click(function(e){
    e.preventDefault();
     var imgSrc = $(this).attr('href');
     var imgFind = $(".flickity-slider > div > a ").each(function(){ 
                   if($(this).attr('href') == imgSrc){
                       $(this).closest('div').css({"position": "absolute", "left": "0%"});  
                    } 

             });

});

Code Motive: When user click on thumbnail image =, this fucntion get the "href" attribute of the clicked image. This "href" and image src is same that i want to display in product image div. i also add some css in jquery code for display the image. Everything is working fine.

Issue is: Suppose 4 thumbnails appearing as ascending order like"

THUNMB1 THUNMB2 THUNMB3 THUNMB4

When i click first time thumb1,thumb2,thumb3,thumb4 it works, But when click like this order

1.) Click thumb1 works good
2.) Click thumb2 works good
3.) Click thumb3 works good
4.) **Click thumb2 Not works after that nothing works when i click on previously clicked thumbnail again. This is the main issue**

Thanks! Plz help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire