如何在Java脚本中转换此代码 [英] how to convert this code in java script

查看:124
本文介绍了如何在Java脚本中转换此代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

textbox.SelectAll();
textbox.SelectionStart = 0;



就像我在代码中使用它一样.
为此,当我的客户当时单击文本框时,请选择所有文本,然后按123等,然后在此处键入.
默认情况下,我的文本框中为0.00.

那我怎么写



as i am using this in my code.
for the purpose when my client click on text box at that time select all text and when he press 123 etc then it type there.
by default there is 0.00 in my text box.

so how can i write

textboxId.SelectAll();
textboxId.SelectionStart = 0;



在我的javascript函数中.



in my javascript function.

推荐答案

< input type ="text" onfocus ="this.select()" onMouseUp ="return false"/>

或:

<input type="text" onfocus="this.select()" onMouseUp="return false" />

or :

<script type="text/javascript">
    function selectAll(id) {
        var textBox = document.getElementById(id);
        textBox.select();
        textBox.readOnly = true;
        textBox.onmouseup = function() {
            textBox.select();
            return false;
        };
        textBox.onmousedown = function() {
            textBox.select();
            return false;
        };
    };
</script>


这篇关于如何在Java脚本中转换此代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆