tags:

views:

256

answers:

1

hey guys

i looking for a way to preview the text while im typing in a textarea in jquery

exactly what u are using for Stackoverflow ,

+6  A: 
<script>
    $(document).ready(function(){
        $('#someTextBox').keyup(function(){
            $('#target').html(this.val());
        });
    });
</script>

<textarea id="someTextBox"></textarea>
<div id="target"></div>

As you type text in the <textarea>, the text should be copied to the HTML of the <div>.

Justin Niessner
+1. You should promote jQuery's shorthand document ready with `$(function(){...});`
David Murdoch
@Justin, either use `this.value` or `$(this).val()`.
Gaby
@David Murdoch, I am not so sure about that.Its an old debate. It is much more readable even if its a bit longer way
adardesign
eh, usually document ready is at the very top the of the script element/file and I find that readability isn't ever an issue. But if you are burying `$(document).ready(...)` within other code for some odd reason I totally agree with you.
David Murdoch
hey guys i need to use my php function to show slugged title how can i use php function between jquery codes ?
Mac Taylor