开发者

Text Input Box With Instant Content Duplication

I want to have users be able to enter data into a text box and instantly have that text appear in another div as content with a character li开发者_高级运维mit on the input box.

Much like how SO does it when asking a question but for a different application.

I am using the YUI3 framework if that makes any difference.

Unfortunately I don't know where to start so any help is appreciated.

Thanks!


Something like this should work:

<input type="text" id="text1" onchange="document.getElementById('div1').innerHTML=document.getElementById('text1').value">

<div id="div1">
</div>

But I would place a function in the onChange event instead of writing the code in the tag.


Needed to use 'onkeyup' and it worked properly.

<input type="text" id="text1" onkeyup="document.getElementById('div1').innerHTML=document.getElementById('text1').value">

<div id="div1">

</div>

Thanks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜