jq parseintjq手册下载在哪个位置

JQ val() js运算出现NaN 急_百度知道
JQ val() js运算出现NaN 急
js内容 $(&input&).keyup(function(){
if ($(&.P&).val() != && &&
$(&.R&).val() != && &&
$(&.T&).val() != &&){
var p = parseInt($(&.P&).val());
var r = parseInt($(&.R&).val());
var t = parseInt($(&.t&).val());
var i = p * r *
$(&.I&).val(p * r * t);
$(&.FA&).val(p + i);
} });Html内容&input type=&text& class=&P form-control& placeholder=&Your Inital Amount& /&&input type=&text& class=&R form-control& placeholder=&Interest In Decimals& /&&input type=&text& class=&T form-control& placeholder=&Years& /&&input type=&text& class=&I form-control& placeholder=&How Much You Get& /&&input type=&text& class=&FA form-control& placeholder=&Final Amount You Have& /&计算写入input 现 NaN
提问者采纳
写错var&t&=&parseInt($(&.t&).val());//&修改parseInt($(&.T&).val());原错误写 实际parseInt(undeifined)运行NaNNaN任何计算结都NaN
js分大小写么…
大小写敏感
提问者评价
太给力了,你的回答完美的解决了我问题!
其他类似问题
为您推荐:
其他1条回答
刚才测试健壮应该拿则类滤接受数字或者滤掉除数字外其字符我怀疑输入候混入其字符inputkeyup事件绑定添加句this.value=this.value.replace(/\D/gi,'');放前边
val的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁jQuery 参考手册 - 选择器
jQuery 参考手册 - 选择器
jQuery 选择器
$(&#lastname&)
id=&lastname& 的元素
$(&.intro&)
所有 class=&intro& 的元素
所有 &p& 元素
.class.class
$(&.intro.demo&)
所有 class=&intro& 且 class=&demo& 的元素
$(&p:first&)
第一个 &p& 元素
$(&p:last&)
最后一个 &p& 元素
$(&tr:even&)
所有偶数 &tr& 元素
$(&tr:odd&)
所有奇数 &tr& 元素
$(&ul li:eq(3)&)
列表中的第四个元素(index 从 0 开始)
$(&ul li:gt(3)&)
列出 index 大于 3 的元素
$(&ul li:lt(3)&)
列出 index 小于 3 的元素
:not(selector)
$(&input:not(:empty)&)
所有不为空的 input 元素
$(&:header&)
所有标题元素 &h1& - &h6&
所有动画元素
$(&:contains('W3School')&)
包含指定字符串的所有元素
$(&:empty&)
无子(元素)节点的所有元素
$(&p:hidden&)
所有隐藏的 &p& 元素
$(&table:visible&)
所有可见的表格
$(&th,td,.intro&)
所有带有匹配选择的元素
$(&[href]&)
所有带有 href 属性的元素
$(&[href='#']&)
所有 href 属性的值等于 &#& 的元素
$(&[href!='#']&)
所有 href 属性的值不等于 &#& 的元素
$(&[href$='.jpg']&)
所有 href 属性的值包含以 &.jpg& 结尾的元素
$(&:input&)
所有 &input& 元素
$(&:text&)
所有 type=&text& 的 &input& 元素
$(&:password&)
所有 type=&password& 的 &input& 元素
$(&:radio&)
所有 type=&radio& 的 &input& 元素
$(&:checkbox&)
所有 type=&checkbox& 的 &input& 元素
$(&:submit&)
所有 type=&submit& 的 &input& 元素
$(&:reset&)
所有 type=&reset& 的 &input& 元素
$(&:button&)
所有 type=&button& 的 &input& 元素
$(&:image&)
所有 type=&image& 的 &input& 元素
$(&:file&)
所有 type=&file& 的 &input& 元素
$(&:enabled&)
所有激活的 input 元素
$(&:disabled&)
所有禁用的 input 元素
$(&:selected&)
所有被选取的 input 元素
$(&:checked&)
所有被选中的 input 元素基本筛选器
表单对象属性
jQuery 核心函数
jQuery 对象访问
HTML代码/文本/值
浏览器及特性检测
数组和对象操作
字符串操作parseInt with jQuery - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
Can someone help me figuring out why the following jQuery code doesn't work?
I want to return a integer from an user input.
var test = parseInt($("#testid"));
Thank you & bye!
closed as too localized by , , ,
This question is unlikely to help it is only relevant to a small geographic area, a specific moment in time,
or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making
this question more broadly applicable, .If this question can be reworded to fit the rules in the , please .
var test = parseInt($("#testid").val(), 10);
You have to tell it you want the value of the input you are targeting.
And also, always provide the second argument (radix) to parseInt.
It tries to be too clever and autodetect it if not provided and can lead to unexpected results.
Providing 10 assumes you are wanting a base 10 number.
37.8k1387129
Two issues:
You're passing the jQuery wrapper of the element into parseInt, which isn't what you want, as parseInt will call toString on it and get back "[object Object]". You need to use
or something (depending on what the element is) to get the string you want.
You're not telling parseInt what radix (number base) it should use, which puts you at risk of odd input giving you odd results when parseInt guesses which radix to use.
Fix if the element is a form field:
vvvvv-- use val to get the value
var test = parseInt($("#testid").val(), 10);
^^^^-- tell parseInt to use decimal (base 10)
Fix if the element is something else and you want to use the text within it:
vvvvvv-- use text to get the text
var test = parseInt($("#testid").text(), 10);
^^^^-- tell parseInt to use decimal (base 10)
213k47410480
433k69674814
var test = parseInt($("#testid").val());
2,64121423
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledjQuery 参考手册 - 事件
jQuery 参考手册 - 事件
jQuery 事件方法
事件方法会触发匹配元素的事件,或将函数绑定到所有匹配元素的某个事件。
触发实例:
$(&button#demo&).click()
上面的例子将触发 id=&demo& 的 button 元素的 click 事件。
绑定实例:
$(&button#demo&).click(function(){$(&img&).hide()})
上面的例子会在点击 id=&demo& 的按钮时隐藏所有图像。
向匹配元素附加一个或更多事件处理器
触发、或将函数绑定到指定元素的 blur 事件
触发、或将函数绑定到指定元素的 change 事件
触发、或将函数绑定到指定元素的 click 事件
触发、或将函数绑定到指定元素的 double click 事件
向匹配元素的当前或未来的子元素附加一个或多个事件处理器
移除所有通过 live() 函数添加的事件处理程序。
触发、或将函数绑定到指定元素的 error 事件
返回 event 对象上是否调用了 event.preventDefault()。
相对于文档左边缘的鼠标位置。
相对于文档上边缘的鼠标位置。
阻止事件的默认动作。
包含由被指定事件触发的事件处理器返回的最后一个值。
触发该事件的 DOM 元素。
该属性返回从 1970 年 1 月 1 日到事件发生时的毫秒数。
描述事件的类型。
指示按了哪个键或按钮。
触发、或将函数绑定到指定元素的 focus 事件
触发、或将函数绑定到指定元素的 key down 事件
触发、或将函数绑定到指定元素的 key press 事件
触发、或将函数绑定到指定元素的 key up 事件
为当前或未来的匹配元素添加一个或多个事件处理器
触发、或将函数绑定到指定元素的 load 事件
触发、或将函数绑定到指定元素的 mouse down 事件
触发、或将函数绑定到指定元素的 mouse enter 事件
触发、或将函数绑定到指定元素的 mouse leave 事件
触发、或将函数绑定到指定元素的 mouse move 事件
触发、或将函数绑定到指定元素的 mouse out 事件
触发、或将函数绑定到指定元素的 mouse over 事件
触发、或将函数绑定到指定元素的 mouse up 事件
向匹配元素添加事件处理器。每个元素只能触发一次该处理器。
文档就绪事件(当 HTML 文档就绪可用时)
触发、或将函数绑定到指定元素的 resize 事件
触发、或将函数绑定到指定元素的 scroll 事件
触发、或将函数绑定到指定元素的 select 事件
触发、或将函数绑定到指定元素的 submit 事件
绑定两个或多个事件处理器函数,当发生轮流的 click 事件时执行。
所有匹配元素的指定事件
第一个被匹配元素的指定事件
从匹配元素移除一个被添加的事件处理器
从匹配元素移除一个被添加的事件处理器,现在或将来
触发、或将函数绑定到指定元素的 unload 事件}

我要回帖

更多关于 jq手册下载 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信