[6][A.Thông điệp][slider-top-big][nothing]
You are here: Home / (Jquery) Hiển thị HTML trong khi gõ code vào TextArea

(Jquery) Hiển thị HTML trong khi gõ code vào TextArea

| No comment
Trong bài viết này sẽ hướng dẫn bạn cách hiển thị một code HTML bằng Jquery trong khi gõ code vào textarea.

Đầu tiên mời bạn xem Demo :

http://www.erhay.com/p/tao.html

(Sau khi bấm lấy code -> Xem demo -> Bạn có thể nhập thêm mã HTML để thấy sự thay đổi)

Code cho Demo này :



<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function(){
        $('#myTextArea').keyup(function() {
    $('#target').html($(this).val());
});
    });
</script>
Nhập code vào đây : <br/>
<textarea id="myTextArea"></textarea>
<br/>
<div id="target">
</div>


Chúc bạn thực hiện thành công các hướng dẫn trong bài viết này.