-1

我将如何实现以下目标:

  1. 当我单击时run button,它应该隐藏并显示stop button

  2. 单击 时run button,它将执行已经编码的语句,例如仍然可以单击 a并且previous仍在显示next buttonstop button

  3. 当我单击 时stop button,它应该隐藏自身并显示run button.

  4. 它应该退出或停止打算由run button

这是我一开始想到的,我该怎么做才能正确(算法|伪代码|简单演示代码)

  $('#run').click(function e(){
  //hide #run
  //show #stop

  //execute statements x
  //prev and next button must still be clickable here

  $('#stop').click(function e(){
  //hide #stop
  //show #run
  //go outside run to stop execute statements x
  });

  });
4

1 回答 1

1

这将处理您描述的按钮行为。停止声明的业务将取决于他们在做什么以及如何做。需要更多信息来回答这个问题。

$('#run').on('click', function(){
  $('#run').hide();
  $('#stop, #previous, #next').show();
  executeStatements();
});

$('#stop').on('click', function(){
  $('#run').show();
  $('#stop, #previous, #next').hide();
  // 
  // stopExecutingStatements();
  //
});
于 2013-09-04T13:58:21.927 回答