-1

I am trying to execute multiple functions in a sequence when the user does a click on a button.

The problem I am having is that if I place one function after the other like this :

nextTooltipButton.onclick = function () {


          if (self._introItems.length - 1 != self._currentStep) {
              _nextStep.call(self);
          }

          $("#contenedorPage").scrollLeft(0);
          $("#contenedorPage").trigger("scroll");
      };

They execute either at the same time or the second one does not execute.

I come from c# where you can add various controllers (functions) to an event and they will be executed in the order in which you added them to the event.

Is there a way of doing something similar in Javascript?

4

1 回答 1

3

当您使用 jQuery 时,您可以或链接调用,或使用回调(如果可用)。

链接:

$("#contenedorPage").scrollLeft(0).trigger("scroll");

此外,为什么不使用 jQuery 编写所有内容呢?

$("#nextTooltipButton").on("click", function () {
    if ($(this)._introItems.length - 1 != $(this)._currentStep)
        _nextStep.call($(this));

    $("#contenedorPage").scrollLeft(0).trigger("scroll");
};
于 2013-07-24T15:56:44.717 回答