admin管理员组文章数量:1399839
Assume I have a radio button and it returns value as -1
, -2
, 3
or
4
etc. what is the type of value it throws? Is it string or integer?
eg.:
<input type="radio" name="case-type" class="ButtonState" id="Electrician" value="-1" />
<label class="Button" for="Electrician"> Electrician </label>
<input type="radio" name="case-type" class="ButtonState" id="Plumber" value="-2" />
what does is the type of -1 or -2 here, should i use an integer variable to bind those values in my code or should i bind the variables in string variables?
<label class="Button" for="Plumber">Plumber</label>
Assume I have a radio button and it returns value as -1
, -2
, 3
or
4
etc. what is the type of value it throws? Is it string or integer?
eg.:
<input type="radio" name="case-type" class="ButtonState" id="Electrician" value="-1" />
<label class="Button" for="Electrician"> Electrician </label>
<input type="radio" name="case-type" class="ButtonState" id="Plumber" value="-2" />
what does is the type of -1 or -2 here, should i use an integer variable to bind those values in my code or should i bind the variables in string variables?
<label class="Button" for="Plumber">Plumber</label>
Share
Improve this question
edited Aug 10, 2018 at 14:25
k.vincent
4,1638 gold badges43 silver badges85 bronze badges
asked Aug 10, 2018 at 13:55
faizefaize
591 silver badge12 bronze badges
2
- 1 It is a string. – Jonas Wilms Commented Aug 10, 2018 at 13:56
-
in your browser console:
typeof document.querySelector('input[name="case-type"]').value
would equal "string" – James LeClair Commented Aug 10, 2018 at 14:00
1 Answer
Reset to default 10The value
of an input
element is always a string (spec | MDN).
On modern browsers, specialized input elements (type="number"
, type="date"
) have additional properties (valueAsNumber
, valueAsDate
), but value
is always a string.
本文标签: javascriptwhat is the return type of a radio button value is it integer or stringStack Overflow
版权声明:本文标题:javascript - what is the return type of a radio button value is it integer or string - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744151867a2593093.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论