|
工具版本兼容问题
常用的循环语句有: for, while, do-while, for-each
都是用于在满足条件的前提下,重复执行代码用的
关键字 |
简介 |
示例代码 |
for
|
循环语句
|
示例代码
|
while
|
循环语句
|
示例代码
|
do-while
|
循环语句,至少执行一次
|
示例代码
|
forEach
|
增强型循环语句
|
示例代码
|
continue
|
继续下一次循环
|
示例代码
|
break
|
终止循环
|
示例代码
|
示例
1
:
循环语句
示例
2
:
循环语句
示例
3
:
循环语句,至少执行一次
示例
4
:
增强型循环语句
示例
5
:
继续下一次循环
示例
6
:
终止循环
使用 for打印0-4 注意: 进行循环的时候,一定要设置好自增和结束条件,否则会导致无限循环,浏览器直接挂掉。我已经被坑了很多次了。
");
window.frames["iframe_show1110"].document.write(decodeHtml($("textarea#stepcodeTextarea1110").val()));
window.frames["iframe_show1110"].document.close();
$(window.frames["iframe_show1110"]).load(function(){
$("#iframe_show1110").height($("#iframe_show1110").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1110").height($("#iframe_show1110").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用for循环打印 0 到 4<br>");
for(var i=0;i<5;i++){
p(i);
}
</script>
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用for循环打印 0 到 4<br>");
for(var i=0;i<5;i++){
p(i);
}
</script>
");
window.frames["iframe1110"].document.write(decodeHtml(code1110));
window.frames["iframe1110"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1110"]).load(function(){
$("#iframe1110").height($("#iframe1110").contents().find("body").height()+showittryitheight);
});
$("#iframe1110").height($("#iframe1110").contents().find("body").height()+showittryitheight);
alreadyWriteCode1110 = code1110;
$("#rendering1110").hide();
$("#rendered1110").show();
}
var tRereshRetry2DemoPanel1110 = setInterval(rereshRetry2DemoPanel1110,1000);
var binded1110 = false;
$("textarea#stepcodeTextarea1110").keyup(function(){
if(!binded1110){
$(window).bind('beforeunload',function(){
binded1110 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1110 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1110!=newCode){
// window.frames["iframe1110"].document.write("
");
// window.frames["iframe1110"].document.write(decodeHtml($("textarea#stepcodeTextarea1110").val()));
// window.frames["iframe1110"].document.close();
// $(window.frames["iframe1110"]).load(function(){
// $("#iframe1110").height($("#iframe1110").contents().find("body").height()+showittryitheight);
// });
// code1110 = newCode;
// }
});
$(".tryButton1110").click(function(){
$("#tryDiv1110").show();
$("#stepcodeTextarea1110").focus();
$("#stepcodeTextarea1110").height(200);
$("#iframe1110").height(0);
window.frames["iframe1110"].document.write("
");
window.frames["iframe1110"].document.write(decodeHtml($("textarea#stepcodeTextarea1110").val()));
window.frames["iframe1110"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1110"]).load(function(){
$("#iframe1110").height($("#iframe1110").contents().find("body").height()+showittryitheight);
});
$("#iframe1110").height($("#iframe1110").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1110.focus();
editor1110.setSize(null, "250");
$("#rendering1110").hide();
$("#rendered1110").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor1110 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1110"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor1110.on("change",function(doc){
if(!binded1110){
$(window).bind('beforeunload',function(){
binded1110 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1110 = newCode;
$("textarea#stepcodeTextarea1110").val(newCode);
if(alreadyWriteCode1110!=code1110){
lastModifedTime1110 = new Date().getTime();
$("#rendering1110").show();
$("#rendered1110").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1110 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1110.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1110").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
其实 while就是另一种形式的for 使用while打印0-4 注意: 进行循环的时候,一定要设置好自增和结束条件,否则会导致无限循环,浏览器直接挂掉。我已经被坑了很多次了。
");
window.frames["iframe_show1111"].document.write(decodeHtml($("textarea#stepcodeTextarea1111").val()));
window.frames["iframe_show1111"].document.close();
$(window.frames["iframe_show1111"]).load(function(){
$("#iframe_show1111").height($("#iframe_show1111").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1111").height($("#iframe_show1111").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
document.write("使用while循环打印 0 到 4<br>");
function p(s){
document.write(s);
document.write("<br>");
}
var i = 0;
while(i<5){
p(i);
i++;
}
</script>
<script>
document.write("使用while循环打印 0 到 4<br>");
function p(s){
document.write(s);
document.write("<br>");
}
var i = 0;
while(i<5){
p(i);
i++;
}
</script>
");
window.frames["iframe1111"].document.write(decodeHtml(code1111));
window.frames["iframe1111"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1111"]).load(function(){
$("#iframe1111").height($("#iframe1111").contents().find("body").height()+showittryitheight);
});
$("#iframe1111").height($("#iframe1111").contents().find("body").height()+showittryitheight);
alreadyWriteCode1111 = code1111;
$("#rendering1111").hide();
$("#rendered1111").show();
}
var tRereshRetry2DemoPanel1111 = setInterval(rereshRetry2DemoPanel1111,1000);
var binded1111 = false;
$("textarea#stepcodeTextarea1111").keyup(function(){
if(!binded1111){
$(window).bind('beforeunload',function(){
binded1111 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1111 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1111!=newCode){
// window.frames["iframe1111"].document.write("
");
// window.frames["iframe1111"].document.write(decodeHtml($("textarea#stepcodeTextarea1111").val()));
// window.frames["iframe1111"].document.close();
// $(window.frames["iframe1111"]).load(function(){
// $("#iframe1111").height($("#iframe1111").contents().find("body").height()+showittryitheight);
// });
// code1111 = newCode;
// }
});
$(".tryButton1111").click(function(){
$("#tryDiv1111").show();
$("#stepcodeTextarea1111").focus();
$("#stepcodeTextarea1111").height(200);
$("#iframe1111").height(0);
window.frames["iframe1111"].document.write("
");
window.frames["iframe1111"].document.write(decodeHtml($("textarea#stepcodeTextarea1111").val()));
window.frames["iframe1111"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1111"]).load(function(){
$("#iframe1111").height($("#iframe1111").contents().find("body").height()+showittryitheight);
});
$("#iframe1111").height($("#iframe1111").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1111.focus();
editor1111.setSize(null, "250");
$("#rendering1111").hide();
$("#rendered1111").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor1111 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1111"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor1111.on("change",function(doc){
if(!binded1111){
$(window).bind('beforeunload',function(){
binded1111 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1111 = newCode;
$("textarea#stepcodeTextarea1111").val(newCode);
if(alreadyWriteCode1111!=code1111){
lastModifedTime1111 = new Date().getTime();
$("#rendering1111").show();
$("#rendered1111").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1111 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1111.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1111").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
其实do-while与while的区别在于,至少会执行一次 使用do-while打印0-4 注意: 进行循环的时候,一定要设置好自增和结束条件,否则会导致无限循环,浏览器直接挂掉。我已经被坑了很多次了。
");
window.frames["iframe_show1112"].document.write(decodeHtml($("textarea#stepcodeTextarea1112").val()));
window.frames["iframe_show1112"].document.close();
$(window.frames["iframe_show1112"]).load(function(){
$("#iframe_show1112").height($("#iframe_show1112").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1112").height($("#iframe_show1112").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用do-while循环打印 0 到 4<br>");
var i = 0;
do{
p(i);
i++;
} while(i<5);
</script>
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用do-while循环打印 0 到 4<br>");
var i = 0;
do{
p(i);
i++;
} while(i<5);
</script>
");
window.frames["iframe1112"].document.write(decodeHtml(code1112));
window.frames["iframe1112"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1112"]).load(function(){
$("#iframe1112").height($("#iframe1112").contents().find("body").height()+showittryitheight);
});
$("#iframe1112").height($("#iframe1112").contents().find("body").height()+showittryitheight);
alreadyWriteCode1112 = code1112;
$("#rendering1112").hide();
$("#rendered1112").show();
}
var tRereshRetry2DemoPanel1112 = setInterval(rereshRetry2DemoPanel1112,1000);
var binded1112 = false;
$("textarea#stepcodeTextarea1112").keyup(function(){
if(!binded1112){
$(window).bind('beforeunload',function(){
binded1112 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1112 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1112!=newCode){
// window.frames["iframe1112"].document.write("
");
// window.frames["iframe1112"].document.write(decodeHtml($("textarea#stepcodeTextarea1112").val()));
// window.frames["iframe1112"].document.close();
// $(window.frames["iframe1112"]).load(function(){
// $("#iframe1112").height($("#iframe1112").contents().find("body").height()+showittryitheight);
// });
// code1112 = newCode;
// }
});
$(".tryButton1112").click(function(){
$("#tryDiv1112").show();
$("#stepcodeTextarea1112").focus();
$("#stepcodeTextarea1112").height(200);
$("#iframe1112").height(0);
window.frames["iframe1112"].document.write("
");
window.frames["iframe1112"].document.write(decodeHtml($("textarea#stepcodeTextarea1112").val()));
window.frames["iframe1112"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1112"]).load(function(){
$("#iframe1112").height($("#iframe1112").contents().find("body").height()+showittryitheight);
});
$("#iframe1112").height($("#iframe1112").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1112.focus();
editor1112.setSize(null, "250");
$("#rendering1112").hide();
$("#rendered1112").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor1112 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1112"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor1112.on("change",function(doc){
if(!binded1112){
$(window).bind('beforeunload',function(){
binded1112 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1112 = newCode;
$("textarea#stepcodeTextarea1112").val(newCode);
if(alreadyWriteCode1112!=code1112){
lastModifedTime1112 = new Date().getTime();
$("#rendering1112").show();
$("#rendered1112").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1112 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1112.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1112").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
forEach是增强的for循环,主要用于遍历数组。 因为目前还没有学习到数组,所以暂时不讲解。 可以通过这个 链接,跳转到forEach的学习
continue 表示放弃本次循环,进行下一次循环
");
window.frames["iframe_show2105"].document.write(decodeHtml($("textarea#stepcodeTextarea2105").val()));
window.frames["iframe_show2105"].document.close();
$(window.frames["iframe_show2105"]).load(function(){
$("#iframe_show2105").height($("#iframe_show2105").contents().find("body").height()+showittryitheight);
});
$("#iframe_show2105").height($("#iframe_show2105").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用for循环打印 0 到 4<br>如果发现是3,就<span style='color:red'>放弃本次循环,并且进入下一次</span>循环<br>");
for(i=0;i<5;i++){
if(i==3)
continue;
p(i);
}
</script>
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用for循环打印 0 到 4<br>如果发现是3,就<span style='color:red'>放弃本次循环,并且进入下一次</span>循环<br>");
for(i=0;i<5;i++){
if(i==3)
continue;
p(i);
}
</script>
");
window.frames["iframe2105"].document.write(decodeHtml(code2105));
window.frames["iframe2105"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe2105"]).load(function(){
$("#iframe2105").height($("#iframe2105").contents().find("body").height()+showittryitheight);
});
$("#iframe2105").height($("#iframe2105").contents().find("body").height()+showittryitheight);
alreadyWriteCode2105 = code2105;
$("#rendering2105").hide();
$("#rendered2105").show();
}
var tRereshRetry2DemoPanel2105 = setInterval(rereshRetry2DemoPanel2105,1000);
var binded2105 = false;
$("textarea#stepcodeTextarea2105").keyup(function(){
if(!binded2105){
$(window).bind('beforeunload',function(){
binded2105 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code2105 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code2105!=newCode){
// window.frames["iframe2105"].document.write("
");
// window.frames["iframe2105"].document.write(decodeHtml($("textarea#stepcodeTextarea2105").val()));
// window.frames["iframe2105"].document.close();
// $(window.frames["iframe2105"]).load(function(){
// $("#iframe2105").height($("#iframe2105").contents().find("body").height()+showittryitheight);
// });
// code2105 = newCode;
// }
});
$(".tryButton2105").click(function(){
$("#tryDiv2105").show();
$("#stepcodeTextarea2105").focus();
$("#stepcodeTextarea2105").height(200);
$("#iframe2105").height(0);
window.frames["iframe2105"].document.write("
");
window.frames["iframe2105"].document.write(decodeHtml($("textarea#stepcodeTextarea2105").val()));
window.frames["iframe2105"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe2105"]).load(function(){
$("#iframe2105").height($("#iframe2105").contents().find("body").height()+showittryitheight);
});
$("#iframe2105").height($("#iframe2105").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor2105.focus();
editor2105.setSize(null, "250");
$("#rendering2105").hide();
$("#rendered2105").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor2105 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea2105"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor2105.on("change",function(doc){
if(!binded2105){
$(window).bind('beforeunload',function(){
binded2105 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code2105 = newCode;
$("textarea#stepcodeTextarea2105").val(newCode);
if(alreadyWriteCode2105!=code2105){
lastModifedTime2105 = new Date().getTime();
$("#rendering2105").show();
$("#rendered2105").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor2105 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor2105.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv2105").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show2106"].document.write(decodeHtml($("textarea#stepcodeTextarea2106").val()));
window.frames["iframe_show2106"].document.close();
$(window.frames["iframe_show2106"]).load(function(){
$("#iframe_show2106").height($("#iframe_show2106").contents().find("body").height()+showittryitheight);
});
$("#iframe_show2106").height($("#iframe_show2106").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用for循环打印 0 到 4<br>如果发现是3,就<span style='color:red'>终止循环,循环体结束 </span><br>");
for(i=0;i<5;i++){
if(i==3)
break;
p(i);
}
</script>
<script>
function p(s){
document.write(s);
document.write("<br>");
}
document.write("使用for循环打印 0 到 4<br>如果发现是3,就<span style='color:red'>终止循环,循环体结束 </span><br>");
for(i=0;i<5;i++){
if(i==3)
break;
p(i);
}
</script>
");
window.frames["iframe2106"].document.write(decodeHtml(code2106));
window.frames["iframe2106"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe2106"]).load(function(){
$("#iframe2106").height($("#iframe2106").contents().find("body").height()+showittryitheight);
});
$("#iframe2106").height($("#iframe2106").contents().find("body").height()+showittryitheight);
alreadyWriteCode2106 = code2106;
$("#rendering2106").hide();
$("#rendered2106").show();
}
var tRereshRetry2DemoPanel2106 = setInterval(rereshRetry2DemoPanel2106,1000);
var binded2106 = false;
$("textarea#stepcodeTextarea2106").keyup(function(){
if(!binded2106){
$(window).bind('beforeunload',function(){
binded2106 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code2106 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code2106!=newCode){
// window.frames["iframe2106"].document.write("
");
// window.frames["iframe2106"].document.write(decodeHtml($("textarea#stepcodeTextarea2106").val()));
// window.frames["iframe2106"].document.close();
// $(window.frames["iframe2106"]).load(function(){
// $("#iframe2106").height($("#iframe2106").contents().find("body").height()+showittryitheight);
// });
// code2106 = newCode;
// }
});
$(".tryButton2106").click(function(){
$("#tryDiv2106").show();
$("#stepcodeTextarea2106").focus();
$("#stepcodeTextarea2106").height(200);
$("#iframe2106").height(0);
window.frames["iframe2106"].document.write("
");
window.frames["iframe2106"].document.write(decodeHtml($("textarea#stepcodeTextarea2106").val()));
window.frames["iframe2106"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe2106"]).load(function(){
$("#iframe2106").height($("#iframe2106").contents().find("body").height()+showittryitheight);
});
$("#iframe2106").height($("#iframe2106").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor2106.focus();
editor2106.setSize(null, "250");
$("#rendering2106").hide();
$("#rendered2106").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor2106 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea2106"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor2106.on("change",function(doc){
if(!binded2106){
$(window).bind('beforeunload',function(){
binded2106 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code2106 = newCode;
$("textarea#stepcodeTextarea2106").val(newCode);
if(alreadyWriteCode2106!=code2106){
lastModifedTime2106 = new Date().getTime();
$("#rendering2106").show();
$("#rendered2106").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor2106 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor2106.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv2106").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|