|
示例
1
:
下拉列表
示例
2
:
设置高度
示例
3
:
设置可以多选
示例
4
:
默认选中
");
window.frames["iframe_show366"].document.write(decodeHtml($("textarea#stepcodeTextarea366").val()));
window.frames["iframe_show366"].document.close();
$(window.frames["iframe_show366"]).load(function(){
$("#iframe_show366").height($("#iframe_show366").contents().find("body").height()+showittryitheight);
});
$("#iframe_show366").height($("#iframe_show366").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<select >
<option >苍老师</option>
<option >高树玛利亚</option>
<option >遥美</option>
</select>
<select >
<option >苍老师</option>
<option >高树玛利亚</option>
<option >遥美</option>
</select>
");
window.frames["iframe366"].document.write(decodeHtml(code366));
window.frames["iframe366"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe366"]).load(function(){
$("#iframe366").height($("#iframe366").contents().find("body").height()+showittryitheight);
});
$("#iframe366").height($("#iframe366").contents().find("body").height()+showittryitheight);
alreadyWriteCode366 = code366;
$("#rendering366").hide();
$("#rendered366").show();
}
var tRereshRetry2DemoPanel366 = setInterval(rereshRetry2DemoPanel366,1000);
var binded366 = false;
$("textarea#stepcodeTextarea366").keyup(function(){
if(!binded366){
$(window).bind('beforeunload',function(){
binded366 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code366 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code366!=newCode){
// window.frames["iframe366"].document.write("
");
// window.frames["iframe366"].document.write(decodeHtml($("textarea#stepcodeTextarea366").val()));
// window.frames["iframe366"].document.close();
// $(window.frames["iframe366"]).load(function(){
// $("#iframe366").height($("#iframe366").contents().find("body").height()+showittryitheight);
// });
// code366 = newCode;
// }
});
$(".tryButton366").click(function(){
$("#tryDiv366").show();
$("#stepcodeTextarea366").focus();
$("#stepcodeTextarea366").height(200);
$("#iframe366").height(0);
window.frames["iframe366"].document.write("
");
window.frames["iframe366"].document.write(decodeHtml($("textarea#stepcodeTextarea366").val()));
window.frames["iframe366"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe366"]).load(function(){
$("#iframe366").height($("#iframe366").contents().find("body").height()+showittryitheight);
});
$("#iframe366").height($("#iframe366").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor366.focus();
editor366.setSize(null, "250");
$("#rendering366").hide();
$("#rendered366").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 editor366 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea366"), {
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);
}
}
});
editor366.on("change",function(doc){
if(!binded366){
$(window).bind('beforeunload',function(){
binded366 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code366 = newCode;
$("textarea#stepcodeTextarea366").val(newCode);
if(alreadyWriteCode366!=code366){
lastModifedTime366 = new Date().getTime();
$("#rendering366").show();
$("#rendered366").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor366 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor366.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv366").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show367"].document.write(decodeHtml($("textarea#stepcodeTextarea367").val()));
window.frames["iframe_show367"].document.close();
$(window.frames["iframe_show367"]).load(function(){
$("#iframe_show367").height($("#iframe_show367").contents().find("body").height()+showittryitheight);
});
$("#iframe_show367").height($("#iframe_show367").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<select size="2">
<option >苍老师</option>
<option >高树玛利亚</option>
<option >遥美</option>
</select>
<select size="2">
<option >苍老师</option>
<option >高树玛利亚</option>
<option >遥美</option>
</select>
");
window.frames["iframe367"].document.write(decodeHtml(code367));
window.frames["iframe367"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe367"]).load(function(){
$("#iframe367").height($("#iframe367").contents().find("body").height()+showittryitheight);
});
$("#iframe367").height($("#iframe367").contents().find("body").height()+showittryitheight);
alreadyWriteCode367 = code367;
$("#rendering367").hide();
$("#rendered367").show();
}
var tRereshRetry2DemoPanel367 = setInterval(rereshRetry2DemoPanel367,1000);
var binded367 = false;
$("textarea#stepcodeTextarea367").keyup(function(){
if(!binded367){
$(window).bind('beforeunload',function(){
binded367 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code367 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code367!=newCode){
// window.frames["iframe367"].document.write("
");
// window.frames["iframe367"].document.write(decodeHtml($("textarea#stepcodeTextarea367").val()));
// window.frames["iframe367"].document.close();
// $(window.frames["iframe367"]).load(function(){
// $("#iframe367").height($("#iframe367").contents().find("body").height()+showittryitheight);
// });
// code367 = newCode;
// }
});
$(".tryButton367").click(function(){
$("#tryDiv367").show();
$("#stepcodeTextarea367").focus();
$("#stepcodeTextarea367").height(200);
$("#iframe367").height(0);
window.frames["iframe367"].document.write("
");
window.frames["iframe367"].document.write(decodeHtml($("textarea#stepcodeTextarea367").val()));
window.frames["iframe367"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe367"]).load(function(){
$("#iframe367").height($("#iframe367").contents().find("body").height()+showittryitheight);
});
$("#iframe367").height($("#iframe367").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor367.focus();
editor367.setSize(null, "250");
$("#rendering367").hide();
$("#rendered367").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 editor367 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea367"), {
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);
}
}
});
editor367.on("change",function(doc){
if(!binded367){
$(window).bind('beforeunload',function(){
binded367 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code367 = newCode;
$("textarea#stepcodeTextarea367").val(newCode);
if(alreadyWriteCode367!=code367){
lastModifedTime367 = new Date().getTime();
$("#rendering367").show();
$("#rendered367").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor367 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor367.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv367").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show368"].document.write(decodeHtml($("textarea#stepcodeTextarea368").val()));
window.frames["iframe_show368"].document.close();
$(window.frames["iframe_show368"]).load(function(){
$("#iframe_show368").height($("#iframe_show368").contents().find("body").height()+showittryitheight);
});
$("#iframe_show368").height($("#iframe_show368").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<select size="3" multiple="multiple">
<option >苍老师</option>
<option >高树玛利亚</option>
<option >遥美</option>
</select>
<select size="3" multiple="multiple">
<option >苍老师</option>
<option >高树玛利亚</option>
<option >遥美</option>
</select>
");
window.frames["iframe368"].document.write(decodeHtml(code368));
window.frames["iframe368"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe368"]).load(function(){
$("#iframe368").height($("#iframe368").contents().find("body").height()+showittryitheight);
});
$("#iframe368").height($("#iframe368").contents().find("body").height()+showittryitheight);
alreadyWriteCode368 = code368;
$("#rendering368").hide();
$("#rendered368").show();
}
var tRereshRetry2DemoPanel368 = setInterval(rereshRetry2DemoPanel368,1000);
var binded368 = false;
$("textarea#stepcodeTextarea368").keyup(function(){
if(!binded368){
$(window).bind('beforeunload',function(){
binded368 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code368 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code368!=newCode){
// window.frames["iframe368"].document.write("
");
// window.frames["iframe368"].document.write(decodeHtml($("textarea#stepcodeTextarea368").val()));
// window.frames["iframe368"].document.close();
// $(window.frames["iframe368"]).load(function(){
// $("#iframe368").height($("#iframe368").contents().find("body").height()+showittryitheight);
// });
// code368 = newCode;
// }
});
$(".tryButton368").click(function(){
$("#tryDiv368").show();
$("#stepcodeTextarea368").focus();
$("#stepcodeTextarea368").height(200);
$("#iframe368").height(0);
window.frames["iframe368"].document.write("
");
window.frames["iframe368"].document.write(decodeHtml($("textarea#stepcodeTextarea368").val()));
window.frames["iframe368"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe368"]).load(function(){
$("#iframe368").height($("#iframe368").contents().find("body").height()+showittryitheight);
});
$("#iframe368").height($("#iframe368").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor368.focus();
editor368.setSize(null, "250");
$("#rendering368").hide();
$("#rendered368").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 editor368 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea368"), {
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);
}
}
});
editor368.on("change",function(doc){
if(!binded368){
$(window).bind('beforeunload',function(){
binded368 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code368 = newCode;
$("textarea#stepcodeTextarea368").val(newCode);
if(alreadyWriteCode368!=code368){
lastModifedTime368 = new Date().getTime();
$("#rendering368").show();
$("#rendered368").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor368 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor368.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv368").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
对option元素设置selected="selected" 属性
");
window.frames["iframe_show369"].document.write(decodeHtml($("textarea#stepcodeTextarea369").val()));
window.frames["iframe_show369"].document.close();
$(window.frames["iframe_show369"]).load(function(){
$("#iframe_show369").height($("#iframe_show369").contents().find("body").height()+showittryitheight);
});
$("#iframe_show369").height($("#iframe_show369").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<select size="3" multiple="multiple">
<option >苍老师</option>
<option selected="selected">高树玛利亚</option>
<option selected="selected">遥美</option>
</select>
<select size="3" multiple="multiple">
<option >苍老师</option>
<option selected="selected">高树玛利亚</option>
<option selected="selected">遥美</option>
</select>
");
window.frames["iframe369"].document.write(decodeHtml(code369));
window.frames["iframe369"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe369"]).load(function(){
$("#iframe369").height($("#iframe369").contents().find("body").height()+showittryitheight);
});
$("#iframe369").height($("#iframe369").contents().find("body").height()+showittryitheight);
alreadyWriteCode369 = code369;
$("#rendering369").hide();
$("#rendered369").show();
}
var tRereshRetry2DemoPanel369 = setInterval(rereshRetry2DemoPanel369,1000);
var binded369 = false;
$("textarea#stepcodeTextarea369").keyup(function(){
if(!binded369){
$(window).bind('beforeunload',function(){
binded369 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code369 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code369!=newCode){
// window.frames["iframe369"].document.write("
");
// window.frames["iframe369"].document.write(decodeHtml($("textarea#stepcodeTextarea369").val()));
// window.frames["iframe369"].document.close();
// $(window.frames["iframe369"]).load(function(){
// $("#iframe369").height($("#iframe369").contents().find("body").height()+showittryitheight);
// });
// code369 = newCode;
// }
});
$(".tryButton369").click(function(){
$("#tryDiv369").show();
$("#stepcodeTextarea369").focus();
$("#stepcodeTextarea369").height(200);
$("#iframe369").height(0);
window.frames["iframe369"].document.write("
");
window.frames["iframe369"].document.write(decodeHtml($("textarea#stepcodeTextarea369").val()));
window.frames["iframe369"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe369"]).load(function(){
$("#iframe369").height($("#iframe369").contents().find("body").height()+showittryitheight);
});
$("#iframe369").height($("#iframe369").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor369.focus();
editor369.setSize(null, "250");
$("#rendering369").hide();
$("#rendered369").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 editor369 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea369"), {
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);
}
}
});
editor369.on("change",function(doc){
if(!binded369){
$(window).bind('beforeunload',function(){
binded369 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code369 = newCode;
$("textarea#stepcodeTextarea369").val(newCode);
if(alreadyWriteCode369!=code369){
lastModifedTime369 = new Date().getTime();
$("#rendering369").show();
$("#rendered369").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor369 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor369.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv369").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|