开发者

Setting a value to already be in a text input/textarea

Firstly, I'm using a jQuery plugin called inlineFieldLabel to put labels inside my textareas/text inputs.

I have a multi-part form. The idea is to fill the fields in the first part of the form if you decide to go back.

Now, it seems like I can either disable my jQuery plugin if any fields have been previously filled, or I can somehow work around th开发者_C百科is.

I tried putting something between <textarea> and </textarea>, as well as putting a value attribute into my text input, but it seems that the plugin is blocking that from working.

Is there a way I can simply insert text into the text fields, using jQuery perhaps, in the same manner as a keyboard input (which would cause the plugin to function correctly)?


If you mean have some default text then it's pure HTML:

<input type="text" value="hello I'm default value" />
<textarea>hello I'm default value</textarea>

For input field of type text you need to assign the value attribute and for textarea element just have the value between the tags.

If you mean via jQuery then for both element types you can have:

$("#myInput").val("I come in peace from jQuery");

Where myInput is the ID of the desired element.


You could simulate keypress as this links explains:

Is it possible to simulate key press events programmatically?

Hope this helps. Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜