0

この質問は大幅に編集されています。現在の項目 1 から再度使用できるように、リセット ボタンでこのコードをリセットする必要があります。問題は、現在の項目のみがリセットされ、強調表示されたリスト項目がまだ現在の項目のように設定されていることです。 1ではありませんでした。

 var stuff = new Array();
stuff["li_1"]="ext_1";
stuff["li_2"]="hc_1";
stuff["li_3"]="ext_2";
stuff["li_4"]="ext_3";
stuff["li_5"]="hc_2";
stuff["li_6"]="ext_4";
stuff["li_7"]="hc_3";
stuff["li_8"]="ext_5";
stuff["li_9"]="hc_4";
stuff["li_10"]="ext_6";
stuff["li_11"]="hc_5";      
var currentItem=1;  
var extWrong=false;
var extCorrect=false;
var hcWrong=false;
var hcCorrect=false;

$(document).ready(function(e) {
    //document.ontouchmove = function(e){ e.preventDefault(); }
    $('#li_1').draggable({revert:true} );
    $("#li_1").addClass("highlighted");
    $('.drop_area').droppable({
         tolerance:"pointer",
         drop:function (event, ui) {
            var tmpID=$(ui.draggable).attr("id");
            var droppableID = $(this).attr("id");
            var audioToPlay="";
            $("#" + tmpID).hide();           
            $("#" + stuff[tmpID]).show();
            $("#" + stuff[tmpID]).addClass("highlighted");

            currentItem++;

            var dragType=tmpID.split("_")[1];
            dragType=(dragType=="1" || dragType=="3" ||dragType=="4" ||dragType=="6" ||dragType=="8" ||dragType=="10")?"ext":"hc";
            var dropType=droppableID=="extreme_thoughts"?"ext":"hc";

            if(dragType=="ext" && dropType=="ext"){
                    audioToPlay=extCorrect==false?"IntDragDrop_ExtremeCorrect.mp3":"ding.mp3";
                    extCorrect=true;
            }else if(dragType=="ext" && dropType=="hc"){
                    audioToPlay=extWrong==false?"IntDragDrop_ExtremeIncorrect.mp3":"pop4c.mp3";
                    extWrong=true;
            }else if(dragType=="hc" && dropType=="hc"){
                    audioToPlay=hcCorrect==false?"IntDragDrop_HealthyCorrect.mp3":"ding.mp3";
                    hcCorrect=true;
            }else if(dragType=="hc" && dropType=="ext"){
                audioToPlay=hcWrong==false?"IntDragDrop_HealthyIncorrect.mp3":"pop4c.mp3";
                    hcWrong=true;

            }
            playSound(audioToPlay,"#" + stuff[tmpID],"#" + "li_" + currentItem);

            }

    });

これが私の壊れたボタンです。

$("#restart").click(function(){
  currentItem=1;
    var extWrong=false;
    var extCorrect=false;
    var hcWrong=false;
    var hcCorrect=false;
  $("#ext_1,#ext_2,#ext_3,#ext_4,#ext_5,#ext_6,#hc_1,#hc_2,#hc_3,#hc_4,#hc_5,#congrats").hide()
  $("#li_1,#li_2,#li_3,#li_4,#li_5,#li_6,#li_7,#li_8,#li_9,#li_10,#li_11,#hide_me,#hide_me2").show()
  $("#li_2,#li_3,#li_4,#li_5,#li_6,#li_7,#li_8,#li_9,#li_10,#li_11").removeClass("highlighted");
    alert(currentItem)
});
4

1 に答える 1

2

割り当てにタイプミスがあります。currentItem==1代わりにcurrentItem=1;を実行しています。

于 2013-05-10T16:39:45.830 に答える