做一个在线测试工具,在页面修改代码同时在该页面运行,类似于W3School 的在线测试工具

西域榴莲 2015-10-28 02:25:33
http://www.w3school.com.cn/tiy/t.asp?f=jquery_hide
如题,做一个可以测试jquery的测试工具。类似上面链接的在线测试工具,但想要可以离线测试。
求代码或思路。
...全文
265 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
 <input type="button" value="运行代码" onclick="runCode()"/>  
<table border="1">
    <tr><td><textarea id="ta" role="5" cols="50" style="height:300px;width:500px">
<html>
<head>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script>
        window.onload=function(){
            $("p").click(function () {
                $(this).hide();
            });
        }
    </script>
</head>
<body>
    <p>如果您点击我,我会消失。</p>
    <p>点击我,我会消失。</p>
    <p>也要点击我哦。</p>
</body>
</html>
</textarea></td>
    <td><iframe id="ifrCode" frameborder="0" marginheight="0" marginwidth="0" style="height:300px;width:500px"></iframe></td></tr>
</table>
<script>
    var ta = document.getElementById('ta'), ifrCodeDoc = document.getElementById('ifrCode')
    function runCode() {
        ifrCodeDoc.contentWindow.document.open();
        ifrCodeDoc.contentWindow.document.write(ta.value);
        ifrCodeDoc.contentWindow.document.close();
    }
</script>
少年民仔 2015-10-29
  • 打赏
  • 举报
回复
同一楼,页面两块区域,一边操作,一边用iframe实时更新
slwsss 2015-10-28
  • 打赏
  • 举报
回复
左边一个输入框,右边一个iframe 实时把输入框的内容赋给iframe

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧