我正在嘗試從原本僅用於一個的代碼創建4個圖庫。我承認我幾乎不知道JavaScript是一個自學成才的初學者。我遇到的問題是,當我向字符串添加多個「照片」時,所有4個畫廊都停止工作。我毫不懷疑這是一個簡單的語法修復,但我一直無法找到它,也許我甚至不知道做足夠的搜索,但我希望這裏的某個人能夠提供幫助。JavaScript multistring if function
function showPanel(el){
$('section').slideUp('fast');
$('section#'+el).slideDown(1500);
if (el == 'photos' && 'graphics' && 'web' && 'books') {
$('a.works').fancybox({'titlePosition' : 'inside'});
$('a.works.iframe').fancybox({ 'type' : 'iframe', 'titlePosition' : 'inside'})
$('#da-thumbs > article').hoverdir();
$('#filter a').on('click', function(){
$('#filter a').removeClass('active');
$(this).addClass('active');
});
filter();
} else if(el == 'about') {
$('.about .avatar').remove();
$('.home .avatar').clone().appendTo('.about #avatar');
$('.chart').easyPieChart({
animate : 500,
// ----------------------------
// Custom your chart color here
// ----------------------------
barColor : '#eb5b5e',
size : 110
});
} else if(el == 'contact') {
$('.gmap').mobileGmap();
}
}
首先,你將要使用或者替代和 – Bergi
對於'&&'和''||運營商需要充分的表達式:'如果(條件1 &&條件2 && ...)'這是檢查'el =='photos'' true,然後就是字符串''graphics''也是如此,等等。只是一個字符串總是如此。你會希望使用'||',並確保每次'el =='photos'||都聲明'e1' el =='圖形'|| ...「'。 –
我已經嘗試了所有的建議,但它似乎仍然沒有工作。非常感謝你的幫助! – datieray