如何为“输入类型=文本"定义默认值?不使用属性“值"? [英] How to define a default value for "input type=text" without using attribute 'value'?

查看:59
本文介绍了如何为“输入类型=文本"定义默认值?不使用属性“值"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为输入type = text字段提供一个默认值,如下所示:

I need to give a default value for input type=text field as follows:

<input type="text" size="32" value="" name="fee" />

据我所知,有一种方法可以提供此默认值:

There is one way to give this default value as I know:

<input type="text" size="32" value="1000" name="fee" />

这里是一个问题:是否可以在不使用属性'value'的情况下设置默认值?

Here is the question: Is it possible that I can set the default value without using attribute 'value'?

据我所知,如果我手动设置输入值1000,然后通过Web浏览器查看源,则该值仍为空.因此,我认为可能有一种可以使用的方法.

As I know, if I set the enter the value 1000 manually, and then view the source through web browser the value is still empty. So I think there may be a method that I can use.

推荐答案

您可以使用Javascript.

You can use Javascript.

例如,使用jQuery:

For example, using jQuery:

$(':text').val('1000');

但是,这与使用 value 属性没有什么不同.

However, this won't be any different from using the value attribute.

这篇关于如何为“输入类型=文本"定义默认值?不使用属性“值"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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