|
工具版本兼容问题
<input type="text"> 即表示文本框
并且只能够输入一行
如果要输入多行
使用 文本域<textarea>
注: <input> 标签很特别,一般是不需要写成<input />或者<input></input> 这样的。
并且<input> 这样的写法也是满足标准的
示例
1
:
文本框
示例
2
:
设置文本框的长度
示例
3
:
初始值
示例
4
:
有背景文字的文本框
");
window.frames["iframe_show355"].document.write(decodeHtml($("textarea#stepcodeTextarea355").val()));
window.frames["iframe_show355"].document.close();
$(window.frames["iframe_show355"]).load(function(){
$("#iframe_show355").height($("#iframe_show355").contents().find("body").height()+showittryitheight);
});
$("#iframe_show355").height($("#iframe_show355").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<input type="text">
");
window.frames["iframe355"].document.write(decodeHtml(code355));
window.frames["iframe355"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe355"]).load(function(){
$("#iframe355").height($("#iframe355").contents().find("body").height()+showittryitheight);
});
$("#iframe355").height($("#iframe355").contents().find("body").height()+showittryitheight);
alreadyWriteCode355 = code355;
$("#rendering355").hide();
$("#rendered355").show();
}
var tRereshRetry2DemoPanel355 = setInterval(rereshRetry2DemoPanel355,1000);
var binded355 = false;
$("textarea#stepcodeTextarea355").keyup(function(){
if(!binded355){
$(window).bind('beforeunload',function(){
binded355 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code355 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code355!=newCode){
// window.frames["iframe355"].document.write("
");
// window.frames["iframe355"].document.write(decodeHtml($("textarea#stepcodeTextarea355").val()));
// window.frames["iframe355"].document.close();
// $(window.frames["iframe355"]).load(function(){
// $("#iframe355").height($("#iframe355").contents().find("body").height()+showittryitheight);
// });
// code355 = newCode;
// }
});
$(".tryButton355").click(function(){
$("#tryDiv355").show();
$("#stepcodeTextarea355").focus();
$("#stepcodeTextarea355").height(200);
$("#iframe355").height(0);
window.frames["iframe355"].document.write("
");
window.frames["iframe355"].document.write(decodeHtml($("textarea#stepcodeTextarea355").val()));
window.frames["iframe355"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe355"]).load(function(){
$("#iframe355").height($("#iframe355").contents().find("body").height()+showittryitheight);
});
$("#iframe355").height($("#iframe355").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor355.focus();
editor355.setSize(null, "250");
$("#rendering355").hide();
$("#rendered355").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 editor355 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea355"), {
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);
}
}
});
editor355.on("change",function(doc){
if(!binded355){
$(window).bind('beforeunload',function(){
binded355 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code355 = newCode;
$("textarea#stepcodeTextarea355").val(newCode);
if(alreadyWriteCode355!=code355){
lastModifedTime355 = new Date().getTime();
$("#rendering355").show();
$("#rendered355").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor355 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor355.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv355").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show356"].document.write(decodeHtml($("textarea#stepcodeTextarea356").val()));
window.frames["iframe_show356"].document.close();
$(window.frames["iframe_show356"]).load(function(){
$("#iframe_show356").height($("#iframe_show356").contents().find("body").height()+showittryitheight);
});
$("#iframe_show356").height($("#iframe_show356").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<input type="text" size="10">
<input type="text" size="10">
");
window.frames["iframe356"].document.write(decodeHtml(code356));
window.frames["iframe356"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe356"]).load(function(){
$("#iframe356").height($("#iframe356").contents().find("body").height()+showittryitheight);
});
$("#iframe356").height($("#iframe356").contents().find("body").height()+showittryitheight);
alreadyWriteCode356 = code356;
$("#rendering356").hide();
$("#rendered356").show();
}
var tRereshRetry2DemoPanel356 = setInterval(rereshRetry2DemoPanel356,1000);
var binded356 = false;
$("textarea#stepcodeTextarea356").keyup(function(){
if(!binded356){
$(window).bind('beforeunload',function(){
binded356 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code356 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code356!=newCode){
// window.frames["iframe356"].document.write("
");
// window.frames["iframe356"].document.write(decodeHtml($("textarea#stepcodeTextarea356").val()));
// window.frames["iframe356"].document.close();
// $(window.frames["iframe356"]).load(function(){
// $("#iframe356").height($("#iframe356").contents().find("body").height()+showittryitheight);
// });
// code356 = newCode;
// }
});
$(".tryButton356").click(function(){
$("#tryDiv356").show();
$("#stepcodeTextarea356").focus();
$("#stepcodeTextarea356").height(200);
$("#iframe356").height(0);
window.frames["iframe356"].document.write("
");
window.frames["iframe356"].document.write(decodeHtml($("textarea#stepcodeTextarea356").val()));
window.frames["iframe356"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe356"]).load(function(){
$("#iframe356").height($("#iframe356").contents().find("body").height()+showittryitheight);
});
$("#iframe356").height($("#iframe356").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor356.focus();
editor356.setSize(null, "250");
$("#rendering356").hide();
$("#rendered356").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 editor356 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea356"), {
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);
}
}
});
editor356.on("change",function(doc){
if(!binded356){
$(window).bind('beforeunload',function(){
binded356 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code356 = newCode;
$("textarea#stepcodeTextarea356").val(newCode);
if(alreadyWriteCode356!=code356){
lastModifedTime356 = new Date().getTime();
$("#rendering356").show();
$("#rendered356").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor356 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor356.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv356").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show358"].document.write(decodeHtml($("textarea#stepcodeTextarea358").val()));
window.frames["iframe_show358"].document.close();
$(window.frames["iframe_show358"]).load(function(){
$("#iframe_show358").height($("#iframe_show358").contents().find("body").height()+showittryitheight);
});
$("#iframe_show358").height($("#iframe_show358").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<input type="text" value="有初始值的文本框">
<input type="text" value="有初始值的文本框">
");
window.frames["iframe358"].document.write(decodeHtml(code358));
window.frames["iframe358"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe358"]).load(function(){
$("#iframe358").height($("#iframe358").contents().find("body").height()+showittryitheight);
});
$("#iframe358").height($("#iframe358").contents().find("body").height()+showittryitheight);
alreadyWriteCode358 = code358;
$("#rendering358").hide();
$("#rendered358").show();
}
var tRereshRetry2DemoPanel358 = setInterval(rereshRetry2DemoPanel358,1000);
var binded358 = false;
$("textarea#stepcodeTextarea358").keyup(function(){
if(!binded358){
$(window).bind('beforeunload',function(){
binded358 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code358 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code358!=newCode){
// window.frames["iframe358"].document.write("
");
// window.frames["iframe358"].document.write(decodeHtml($("textarea#stepcodeTextarea358").val()));
// window.frames["iframe358"].document.close();
// $(window.frames["iframe358"]).load(function(){
// $("#iframe358").height($("#iframe358").contents().find("body").height()+showittryitheight);
// });
// code358 = newCode;
// }
});
$(".tryButton358").click(function(){
$("#tryDiv358").show();
$("#stepcodeTextarea358").focus();
$("#stepcodeTextarea358").height(200);
$("#iframe358").height(0);
window.frames["iframe358"].document.write("
");
window.frames["iframe358"].document.write(decodeHtml($("textarea#stepcodeTextarea358").val()));
window.frames["iframe358"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe358"]).load(function(){
$("#iframe358").height($("#iframe358").contents().find("body").height()+showittryitheight);
});
$("#iframe358").height($("#iframe358").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor358.focus();
editor358.setSize(null, "250");
$("#rendering358").hide();
$("#rendered358").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 editor358 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea358"), {
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);
}
}
});
editor358.on("change",function(doc){
if(!binded358){
$(window).bind('beforeunload',function(){
binded358 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code358 = newCode;
$("textarea#stepcodeTextarea358").val(newCode);
if(alreadyWriteCode358!=code358){
lastModifedTime358 = new Date().getTime();
$("#rendering358").show();
$("#rendered358").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor358 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor358.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv358").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
使用属性placeholder
placeholder是一个html5的属性,对于大多数的已经支持html5的浏览器来说,是可以看到效果的,但是对于老的不支持html5的浏览器,比如ie8,就看不到效果
");
window.frames["iframe_show359"].document.write(decodeHtml($("textarea#stepcodeTextarea359").val()));
window.frames["iframe_show359"].document.close();
$(window.frames["iframe_show359"]).load(function(){
$("#iframe_show359").height($("#iframe_show359").contents().find("body").height()+showittryitheight);
});
$("#iframe_show359").height($("#iframe_show359").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<input type="text" placeholder="请输入账号">
<input type="text" placeholder="请输入账号">
");
window.frames["iframe359"].document.write(decodeHtml(code359));
window.frames["iframe359"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe359"]).load(function(){
$("#iframe359").height($("#iframe359").contents().find("body").height()+showittryitheight);
});
$("#iframe359").height($("#iframe359").contents().find("body").height()+showittryitheight);
alreadyWriteCode359 = code359;
$("#rendering359").hide();
$("#rendered359").show();
}
var tRereshRetry2DemoPanel359 = setInterval(rereshRetry2DemoPanel359,1000);
var binded359 = false;
$("textarea#stepcodeTextarea359").keyup(function(){
if(!binded359){
$(window).bind('beforeunload',function(){
binded359 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code359 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code359!=newCode){
// window.frames["iframe359"].document.write("
");
// window.frames["iframe359"].document.write(decodeHtml($("textarea#stepcodeTextarea359").val()));
// window.frames["iframe359"].document.close();
// $(window.frames["iframe359"]).load(function(){
// $("#iframe359").height($("#iframe359").contents().find("body").height()+showittryitheight);
// });
// code359 = newCode;
// }
});
$(".tryButton359").click(function(){
$("#tryDiv359").show();
$("#stepcodeTextarea359").focus();
$("#stepcodeTextarea359").height(200);
$("#iframe359").height(0);
window.frames["iframe359"].document.write("
");
window.frames["iframe359"].document.write(decodeHtml($("textarea#stepcodeTextarea359").val()));
window.frames["iframe359"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe359"]).load(function(){
$("#iframe359").height($("#iframe359").contents().find("body").height()+showittryitheight);
});
$("#iframe359").height($("#iframe359").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor359.focus();
editor359.setSize(null, "250");
$("#rendering359").hide();
$("#rendered359").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 editor359 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea359"), {
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);
}
}
});
editor359.on("change",function(doc){
if(!binded359){
$(window).bind('beforeunload',function(){
binded359 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code359 = newCode;
$("textarea#stepcodeTextarea359").val(newCode);
if(alreadyWriteCode359!=code359){
lastModifedTime359 = new Date().getTime();
$("#rendering359").show();
$("#rendered359").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor359 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor359.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv359").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|