【问题标题】:Real Time Editor实时编辑器
【发布时间】:2017-05-23 19:03:23
【问题描述】:

我试图在页面加载时获取它,它会自动加载我在文本框中的代码,我在想可能使用加载的 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>

【问题讨论】:

    标签: javascript php html domcontentloaded


    【解决方案1】:
    $(document).ready(function(){
      $('#DisplayCode').html($("#Code").val());
        $('#Code').keyup(function(){
            $('#DisplayCode').html($(this).val());
        });
    });
    

    只需在 domready 上执行此操作?

    【讨论】:

    • 是的!谢谢!
    猜你喜欢
    • 2019-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 2020-04-24
    • 2023-03-12
    相关资源
    最近更新 更多