2013-11-01 21 views
0

我的代碼是...怎麼寫的條件,無論是相同的或不同的按鈕點擊

$(document).on("click", ".mp-likedImgs", function() { 
    var mplike= $(this).parent().parent().children().first().attr('id'); 
    if (jQuery.inArray(mplike, unlikedImgsId) != -1) { 
     var delmpLike = unlikedImgsId.indexOf(mplike); 
     unlikedImgsId.splice(delmpLike, 1); 
    } 
     if (jQuery.inArray(mplike, likedImgsId) == -1) { 
     likedImgsId.push(mplike); 
     $(this).find('img').css({'opacity':'1.0'}); 
    } 
    }); 

    //start code for multiple image unlike button 
     $(document).on("click", ".mp-unlikedImgs", function() { 
    var mpunlike= $(this).parent().parent().children().first().attr('id'); 
    if (jQuery.inArray(mpunlike, likedImgsId) != -1) { 
     var delmpUnLike= likedImgsId.indexOf(mpunlike); 
     likedImgsId.splice(delmpUnLike,1); 
     } 
     if (jQuery.inArray(mpunlike, unlikedImgsId) == -1) { 
     unlikedImgsId.push(mpunlike); 
     $(this).find('img').css({'opacity':'1.0'}); 
     } 

    }); 

在全屏模式下我有一個像&不像image.when按鈕我按下像和不像圖像都被點擊&突出顯示,但我想只有一個按鈕被點擊一個圖像或者像或不同。

預先感謝...

回答

0

嘗試用它具有兩個types.like

$(document).on("click", ".mp-UniqueImgs", function() { 

我認爲你正在使用相同functionality.Better使用唯一的類名otherthan mp-UniqueImgs類現在並將這一行動應用於這個新班級。

相關問題