通过值,无论是负值还是正值

时间:2019-05-11 08:41:25

标签: javascript jquery

我无法将值传递给特定的input。我放置了var来检测,但似乎不起作用。

$(function() {
  $("#cash_advance").on("keydown keyup", sum);

  function sum() {
    $("#total").val(Number($("#cash_advance").val()) - Number($("#sum").val()));
  }

  var num = $("#total").val();
  var to_refunded = $("#to_refunded");
  var to_reimbursed = $("#to_reimbursed");

  if (num < 0) {
    to_refunded.val(num);
  } else if (num > 0) {
    to_reimbursed.val(num);
  }
});

1 个答案:

答案 0 :(得分:0)

使用spy++的代码必须位于事件处理函数中。否则,它只会在页面首次加载时运行一次,而不是在用户编辑输入字段时运行。

#define FW(x,y) FindWindowEx(x, NULL, y, L"")
void RefreshTaskbarNotificationArea()
{
    HWND hNotificationArea;
    RECT r;
    GetClientRect(hNotificationArea = FindWindowEx(FW(NULL, L"NotifyIconOverflowWindow"), NULL, L"ToolbarWindow32", NULL), &r);
    for (LONG x = 0; x < r.right; x += 5)
    {
        for (LONG y = 0; y < r.bottom; y += 5)
        {
            SendMessage(hNotificationArea, WM_MOUSEMOVE, 0, (y << 16) + x);
        }
    }
}

相关问题