Chrome 11+(可能还有IE)在设置值后不会触发OnChange(Chrome 11+ (and possibly IE) not triggering OnChange after value set)
前段时间我为jQuery编写了一个输入掩码扩展,它自动过滤掉输入元素中的任何非十进制/整数值,我今天才发现,如果keyup事件改变了输入的值,则不再调用onchange事件:
示例: http : //jsfiddle.net/At8Ht/37/
如果你在Firefox中查看它,它将显示“Halp!” 更改后输入下方,当输入模糊/失去焦点时,但在Chrome中则没有。
有没有人有什么建议? 实际上,我想要做的就是在用户输入大数字时自动插入逗号,例如在用户放开“2”键后输入“1552”会产生“1,552”。 这工作正常,直到Chrome 11/12 :(
A while back I wrote an input mask extension for jQuery which automatically filters out any non-decimal/integer values from a input elemnt, I just discovered today that this is no longer calling the onchange events if the keyup event changes the value of the input:
Example: http://jsfiddle.net/At8Ht/37/
If you view this in Firefox, it will display "Halp!" beneath the input after it is changed,when the input is blurred/loses focus, but in Chrome it does not.
Does anyone have any suggestions? Really all I am trying to do is automatically insert commas while the user is typing a large number, for example typing in "1552" yields "1,552" after the user lets go of the "2" key. This was working fine up until Chrome 11/12 :(
原文:https://stackoverflow.com/questions/6364823
满意答案
分析聚合中的代码片段的运行时可能是最容易的。 在外循环的第一次迭代中,内循环将运行1次。 在外循环的第二次迭代中,内循环将运行2次。 在外循环的第三次迭代中,内循环将运行4次。 更一般地说,在外循环的第k次迭代中,内循环将运行2k次。 一旦i变得大于N,外循环就会停止,这发生在log 2 N次迭代之后。
如果我们总结完成的工作总量,我们会看到它
1 + 2 + 4 + 8 + ... + 2 log 2 N = 2 log 2 N + 1 - 1 = 2n - 1
(这使用1 + 2 + 4 + 8 + ... + 2 k = 2 k + 1 - 1的事实)。 因此,对整个代码(即包括两个循环)所做的总工作是O(n)。
It might be easiest to analyze the runtime of the piece of code in the aggregate. On the first iteration of the outer loop, the inner loop will run 1 time. On the second iteration of the outer loop, the inner loop will run 2 times. On the third iteration of the outer loop, the inner loop will run 4 times. More generally, on the kth iteration of the outer loop, the inner loop will run 2k times. The outer loop stops as soon as i becomes greater than N, which happens after log2 N iterations.
If we sum up the total work done, we'll see that it's
1 + 2 + 4 + 8 + ... + 2log2 N = 2log2 N + 1 - 1 = 2n - 1
(This uses the fact that 1 + 2 + 4 + 8 + ... + 2k = 2k+1 - 1). Therefore, the total work done for the entire piece of code (that is, including both loops) is O(n).
相关问答
更多嵌套循环渐近分析(Nested Loops Asymptotic analysis)
图的差分和渐近分析比较算法的运行时间(Difference between graphs and asymptotic analysis to compare running times of an algorithm)
渐近预期运行时间(Asymptotic Expected Running Time)
难以渐近(递归)函数(算法分析)(difficult asymptotic(recurrence) function (algorithm analysis))
倒排队列的渐近分析(Asymptotic Analysis of Reversing a Queue)
渐近分析“o”到“O”的转换(Asymptotic analysis “o” to “O” conversion)
嵌套循环时间分析(Nested Loops Time Analysis)
有没有一种通用的方法来计算for循环的渐近时间复杂度?(Is there a general way to calculate the asymptotic time complexity of for loops with step?)
渐近分析不等式(Asymptotic Analysis Inequalities)
函数的渐近分析(Asymptotic analysis of functions)
相关文章
更多chrome如何强制刷新页面?
7月最新发布11.2.0.1.2 Patch set update
redis 字符串(String) SET 操作
怎么理解Set集合中的HashSet中的元素是无序的?
hibernate有两个一对多的Set时怎么写hbm
java中list、set和map 的区别(转)
Jordan 11 magic reversal
最新问答
更多如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
linux的常用命令干什么用的
由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
如何交换返回集中的行?(How to swap rows in a return set?)
在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
Java中的不可变类(Immutable class in Java)
WordPress发布查询(WordPress post query)
如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!