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!
相关问题
- Laravel Option Select - Default Issue
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- HTML form is not sending $_POST values
- How to use Control.FromHandle?
Are you looking for
.keyup()
?Look at this fiddle for a simple example: http://jsfiddle.net/LUDWQ/2/
When putting in into a
div
and not another textbox you can use this:Fiddle: http://jsfiddle.net/LUDWQ/4/
If the textarea control has an id of "textarea_control" and the preview div/span/whatever has an id of "preview", you could potentially use something like this (snagged from some code I used in a project and tweaked for your example).
Hope this helps!
Please note, this does not do any filtering of user's input, so you should probably think about calling a separate function to filter the data to prevent injection or other attacks before displaying the preview.