Javascript 实时编辑器
我试图在页面加载时自动加载文本框中的代码,我在想可能使用Dom内容加载?有什么建议吗Javascript 实时编辑器,javascript,php,html,domcontentloaded,Javascript,Php,Html,Domcontentloaded,我试图在页面加载时自动加载文本框中的代码,我在想可能使用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 --> <
<!--- 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>
在这里插入您的代码
$(文档).ready(函数(){
$(“#代码”).keyup(函数(){
$('#DisplayCode').html($(this.val());
});
});
只需在domready上执行此操作?是!非常感谢。
$(document).ready(function(){
$('#DisplayCode').html($("#Code").val());
$('#Code').keyup(function(){
$('#DisplayCode').html($(this).val());
});
});