日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

easy js test--方便对js进行测试,不需要刷新

發布時間:2023/12/15 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 easy js test--方便对js进行测试,不需要刷新 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

若轉載請注明

依賴jquery

<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"?"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>??
<meta?charset="utf-8">??
<title>用于一次性測試js</title>??
<style>
?textarea{width:400px;height:200px;}?
</style>
<script?src="QUnit/resources/jquery-1.9.1.js"></script>
</head>
<body>

?<!--?js編輯區-->
?<p>js編輯區</p>
?<textarea?id="js_area">
?</textarea>
?<div>
??<input?type="button"?οnclick="run();"?value="運行"/>
???<input?type="button"?οnclick="clearJs();"?value="清空"/>
???<input?type="button"?οnclick="createAlert();"?value="alert"/>
???<input?type="button"?οnclick="createGetById();"?value="GetById"/>
?</div>
<!--?html編輯區-->?
?<p>html編輯區</p>
?<textarea?id="html_area">?
?</textarea>
?<div>
???<input?type="button"?οnclick="clearHtml();"?value="清空"/>
???<input?type="button"?οnclick="createDiv();"?value="DIV"/>
???<input?type="button"?οnclick="createSpan();"?value="SPAN"/>
????<input?type="button"?οnclick="createButton();"?value="按鈕"/>
????<input?type="button"?οnclick="createText();"?value="文本框"/>
?????<input?type="button"?οnclick="createSelect();"?value="下拉框"/>
??????<input?type="button"?οnclick="createA();"?value="鏈接"/>
?</div>

?<!--?結果顯示區-->
?<p>結果顯示區</p>
?<div?id="result"></div>

</body>
<script>
??var?run?=?function(){
???//先清空之前的結果
???$("#result").html('');
??var?script?=?$("\<script?type='text/javascript'\>\</script\>");
??script.append($("#js_area").val());
??$("#result").append($("#html_area").val());
??$("#result").append(script);
??}
??var?clearJs?=?function(){
???$("#js_area").val("");
??}
??var?clearHtml?=?function(){
???$("#html_area").val("");
??}

??var?createDiv?=?function(){
????var?content?=?"\<div?id=''\>\</div\>";
????insertAtCursor($("#html_area").get(0),content);
??}

??var?createSpan?=?function(){
????var?content?=?"\<span?id=''\>\</span\>";
????insertAtCursor($("#html_area").get(0),content);
??}
??var?createButton?=?function(){
????var?content?=?"\<input?type='button'?name=''?id=''/\>";
????insertAtCursor($("#html_area").get(0),content);
??}
??var?createText?=?function(){
????var?content?=?"\<input?type='text'?name=''?id=''/\>";
????insertAtCursor($("#html_area").get(0),content);
??}
??var?createSelect?=?function(){
????var?content?=?"\<select?name=''?id=''\>\<option?value=''\>?\<option/\>??\n<select>";
????insertAtCursor($("#html_area").get(0),content);
??}
??var?createA?=?function(){
????var?content?=?"\<a?name=''?id=''?href=''?target=''\>?\</a\>";
????insertAtCursor($("#html_area").get(0),content);
??}
??var?createAlert?=?function(){
????var?content?=?"alert('')";
????insertAtCursor($("#js_area").get(0),content);
??}
??var?createGetById?=?function(){
????var?content?=?"$('#id')";
????insertAtCursor($("#js_area").get(0),content);
??}

??var?insertAtCursor?=?function(obj/*html?object*/,content/*String*/){
???//IE?support
????????if?(document.selection)?
????????{
????????????obj.focus();
????????????var?sel=?document.selection.createRange();
????????????sel.text=?content;
????????????sel.select();
????????//firefox?support
????????}else{
?????????if(typeof?obj.selectionStart?==?'number'){
????????????var?start?=?obj.selectionStart;
????????????var?end?=?obj.selectionEnd;
????????????var?pre?=?obj.value.substr(0,?start);???
???????????var?post?=?obj.value.substr(end);
???????????obj.value?=?pre+?content+post;??
??????????}
????????}
??}
</script>
</html>?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

轉載于:https://blog.51cto.com/leopold/1251489

總結

以上是生活随笔為你收集整理的easy js test--方便对js进行测试,不需要刷新的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。