0

我试图在页面加载时获取它,它会自动加载我在文本框中的代码,我在想也许使用加载的 Dom 内容?有什么建议么?

<!--- Shows the Code that Is inserted into the Text Box -->             

 <div  id="DisplayCode"></div>

<!--- End Of Shows the Code that Is inserted into the Text Box --> 





<!-- Text Box Code Where You input the Code --> 
        <div class="form1">
        <textarea id="Code" value="insert Code Here" rows="14" cols="183" ><!DOCTYPE html>
        <html>
        <body>

        <h1> Insert Your Code Here </h1> 

        </body>
        </html>
           </textarea>  

    <!-- End of Text Box Where You Enter your Code -->





    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $('#Code').keyup(function(){
            $('#DisplayCode').html($(this).val());
        });
    });
    </script>

    </div>
4

1 回答 1

0
$(document).ready(function(){
  $('#DisplayCode').html($("#Code").val());
    $('#Code').keyup(function(){
        $('#DisplayCode').html($(this).val());
    });
});

只需在 domready 上执行此操作?

于 2017-05-23T19:07:23.120 回答