通过文本框自动显示预览 [英] auto show preview from text box

查看:67
本文介绍了通过文本框自动显示预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的网站制作一个帖子页面,我想添加一个自动更新预览框,以显示上面文本框中键入的内容.显然我想使用javascript或jquery.我需要的东西基本上与该网站的询问页面上的东西相同!

I'm making a post page for my website, and I would like to add an auto update preview box, showing what is being typed into the text box above. Obviously i'd like to use javascript, or jquery. And the thing I need is basically the same thing as on the ask page for this website!

推荐答案

您在寻找.keyup()吗?

看一下这个小提琴,举一个简单的例子: http://jsfiddle.net/LUDWQ/2/

Look at this fiddle for a simple example: http://jsfiddle.net/LUDWQ/2/

$('#tb1').keyup(function() {
    $('#tb2').val($('#tb1').val());
});

在放入div而不是另一个文本框时,您可以使用以下命令:

When putting in into a div and not another textbox you can use this:

$('#tb1').keyup(function() {
    $('#tb2').html($('#tb1').val()); //tb2 is a <div> here
});

提琴: http://jsfiddle.net/LUDWQ/4/

这篇关于通过文本框自动显示预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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