How can val() return Number?

后端 未结 5 499
梦谈多话
梦谈多话 2020-11-27 19:28

In the valdocs written this description:

.val() Returns: String, Number, Array

I tried to get a Number, b

5条回答
  •  心在旅途
    2020-11-27 19:59

    I've done a bit of quick peeking around, and I think I have an answer. If you look at the implementation of the val function you can see that if a so-called val-hook is in place, if the val-hook returns a number, that number will be returned as-is from the val function. I found this discussion which suggests that val-hooks are primarily used by plugins to create custom controls, such as sliders, etc., where the "natural" return value of val could be an integer. Hope this sheds a bit of light on your question.

提交回复
热议问题