How can val() return Number?

后端 未结 5 500
梦谈多话
梦谈多话 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:47

    A text input's value attribute will always return a string. You need to parseInt the value to get an integer:

    parseInt($('#myInput').val(), 10);
    

提交回复
热议问题