问题描述
我有一个文本框,我希望每当用户开始在该texbox中输入数字时,都应删除以前的值.
假设有一个包含数字23的文本框,我希望每当用户开始在同一文本框23中输入内容时,都应删除它并显示新的输入数字.
我的代码如下
I have a textbox ,i want whenever user start entering a number in that texbox the previous value should be remove.
Let say there is a textbox which contain a number as 23 ,i want whenever user start typing in that same textbox 23 shold be remove and new enetered number should be shown.
My code as follow
document.getElementById("mytextbox").select();
$("#mytextbox").select();
<input type="text" onclick="clear();">
但是我的代码仍然无法正常工作,我使用的是ie9,窗口7是64位PC,我调试了代码,并对这行做了快速监视
But still my code is not working,i am using ie9 ,window 7 64 bit pc,i debug the code and did quickwatch to this line
document.getElementById("mytextbox").select()
它显示给我未定义.,我能够找到mytextbox.
还有其他方法可以执行此操作.我的代码在chrome和mozilla中运行.
it is showing me undefined.,I am able to find the mytextbox.
Is there any other way to do this.My code is working in chrome and mozilla.
推荐答案
但是我的代码仍然无法正常工作,我使用的是ie9,窗口7是64位PC,我调试了代码,并对这行做了快速监视
But still my code is not working,i am using ie9 ,window 7 64 bit pc,i debug the code and did quickwatch to this line
document.getElementById("mytextbox").select()
它显示给我未定义.,我能够找到mytextbox.
还有其他方法可以执行.我的代码在chrome和mozilla中运行.
it is showing me undefined.,I am able to find the mytextbox.
Is there any other way to do this.My code is working in chrome and mozilla.
<script type="text/javascript">
这篇关于当用户输入新数字或字符并开始输入javascript或jquery时如何删除先前的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!