|
关键字 |
简介 |
示例代码 |
$(document).ready() $() load()
|
加载
|
示例代码
|
click() dblclick()
|
点击
|
示例代码
|
keydown() keypress() keyup
|
键盘
|
示例代码
|
mousedown() mouseup() mousemove() mouseenter() mouseleave() mouseover() mouseout()
|
鼠标
|
示例代码
|
focus() blur()
|
焦点
|
示例代码
|
change()
|
改变
|
示例代码
|
submit()
|
提交
|
示例代码
|
on()
|
绑定事件
|
示例代码
|
trigger()
|
触发事件
|
示例代码
|
示例
1
:
加载
示例
2
:
点击
示例
3
:
键盘
示例
4
:
鼠标
示例
5
:
焦点
示例
6
:
改变
示例
7
:
提交
示例
8
:
绑定事件
示例
9
:
触发事件
页面加载有两种方式表示
1. $(document).ready();
2. $(); 这种比较常用
图片加载用load()函数
");
window.frames["iframe_show991"].document.write(decodeHtml($("textarea#stepcodeTextarea991").val()));
window.frames["iframe_show991"].document.close();
$(window.frames["iframe_show991"]).load(function(){
$("#iframe_show991").height($("#iframe_show991").contents().find("body").height()+showittryitheight);
});
$("#iframe_show991").height($("#iframe_show991").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#message1").html("页面加载成功");
});
$(function(){
$("#img").load(function(){
$("#message2").html("图片加载成功");
});
});
</script>
<div id="message1"></div>
<div id="message2"></div>
<img id="img" src="http://127.0.0.1/example.gif">
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#message1").html("页面加载成功");
});
$(function(){
$("#img").load(function(){
$("#message2").html("图片加载成功");
});
});
</script>
<div id="message1"></div>
<div id="message2"></div>
<img id="img" src="http://127.0.0.1/example.gif">
");
window.frames["iframe991"].document.write(decodeHtml(code991));
window.frames["iframe991"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe991"]).load(function(){
$("#iframe991").height($("#iframe991").contents().find("body").height()+showittryitheight);
});
$("#iframe991").height($("#iframe991").contents().find("body").height()+showittryitheight);
alreadyWriteCode991 = code991;
$("#rendering991").hide();
$("#rendered991").show();
}
var tRereshRetry2DemoPanel991 = setInterval(rereshRetry2DemoPanel991,1000);
var binded991 = false;
$("textarea#stepcodeTextarea991").keyup(function(){
if(!binded991){
$(window).bind('beforeunload',function(){
binded991 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code991 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code991!=newCode){
// window.frames["iframe991"].document.write("
");
// window.frames["iframe991"].document.write(decodeHtml($("textarea#stepcodeTextarea991").val()));
// window.frames["iframe991"].document.close();
// $(window.frames["iframe991"]).load(function(){
// $("#iframe991").height($("#iframe991").contents().find("body").height()+showittryitheight);
// });
// code991 = newCode;
// }
});
$(".tryButton991").click(function(){
$("#tryDiv991").show();
$("#stepcodeTextarea991").focus();
$("#stepcodeTextarea991").height(200);
$("#iframe991").height(0);
window.frames["iframe991"].document.write("
");
window.frames["iframe991"].document.write(decodeHtml($("textarea#stepcodeTextarea991").val()));
window.frames["iframe991"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe991"]).load(function(){
$("#iframe991").height($("#iframe991").contents().find("body").height()+showittryitheight);
});
$("#iframe991").height($("#iframe991").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor991.focus();
editor991.setSize(null, "250");
$("#rendering991").hide();
$("#rendered991").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 editor991 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea991"), {
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);
}
}
});
editor991.on("change",function(doc){
if(!binded991){
$(window).bind('beforeunload',function(){
binded991 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code991 = newCode;
$("textarea#stepcodeTextarea991").val(newCode);
if(alreadyWriteCode991!=code991){
lastModifedTime991 = new Date().getTime();
$("#rendering991").show();
$("#rendered991").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor991 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor991.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv991").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
click() 表示单击
dblclick() 表示双击
注: 空白键和回车键也可以造成click事件,但是只有双击鼠标才能造成dblclick事件
");
window.frames["iframe_show996"].document.write(decodeHtml($("textarea#stepcodeTextarea996").val()));
window.frames["iframe_show996"].document.close();
$(window.frames["iframe_show996"]).load(function(){
$("#iframe_show996").height($("#iframe_show996").contents().find("body").height()+showittryitheight);
});
$("#iframe_show996").height($("#iframe_show996").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#b").click(function(){
$("#message").html("单击按钮");
});
$("#b").dblclick(function(){
$("#message").html("双击按钮");
});
});
</script>
<div id="message"></div>
<button id="b">测试单击和双击</button>
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#b").click(function(){
$("#message").html("单击按钮");
});
$("#b").dblclick(function(){
$("#message").html("双击按钮");
});
});
</script>
<div id="message"></div>
<button id="b">测试单击和双击</button>
");
window.frames["iframe996"].document.write(decodeHtml(code996));
window.frames["iframe996"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe996"]).load(function(){
$("#iframe996").height($("#iframe996").contents().find("body").height()+showittryitheight);
});
$("#iframe996").height($("#iframe996").contents().find("body").height()+showittryitheight);
alreadyWriteCode996 = code996;
$("#rendering996").hide();
$("#rendered996").show();
}
var tRereshRetry2DemoPanel996 = setInterval(rereshRetry2DemoPanel996,1000);
var binded996 = false;
$("textarea#stepcodeTextarea996").keyup(function(){
if(!binded996){
$(window).bind('beforeunload',function(){
binded996 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code996 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code996!=newCode){
// window.frames["iframe996"].document.write("
");
// window.frames["iframe996"].document.write(decodeHtml($("textarea#stepcodeTextarea996").val()));
// window.frames["iframe996"].document.close();
// $(window.frames["iframe996"]).load(function(){
// $("#iframe996").height($("#iframe996").contents().find("body").height()+showittryitheight);
// });
// code996 = newCode;
// }
});
$(".tryButton996").click(function(){
$("#tryDiv996").show();
$("#stepcodeTextarea996").focus();
$("#stepcodeTextarea996").height(200);
$("#iframe996").height(0);
window.frames["iframe996"].document.write("
");
window.frames["iframe996"].document.write(decodeHtml($("textarea#stepcodeTextarea996").val()));
window.frames["iframe996"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe996"]).load(function(){
$("#iframe996").height($("#iframe996").contents().find("body").height()+showittryitheight);
});
$("#iframe996").height($("#iframe996").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor996.focus();
editor996.setSize(null, "250");
$("#rendering996").hide();
$("#rendered996").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 editor996 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea996"), {
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);
}
}
});
editor996.on("change",function(doc){
if(!binded996){
$(window).bind('beforeunload',function(){
binded996 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code996 = newCode;
$("textarea#stepcodeTextarea996").val(newCode);
if(alreadyWriteCode996!=code996){
lastModifedTime996 = new Date().getTime();
$("#rendering996").show();
$("#rendered996").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor996 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor996.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv996").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
keydown 表示按下键盘 keypress 表示按下键盘 keyup 表示键盘弹起 这三者的区别分别表现在发生的 先后顺序,获取到的键盘按钮值,已经对输入框的文本取值这三方面 先后顺序: 按照 keydown keypress keyup 顺序发生 键盘按钮值: 通过event对象的which属性获取键盘的值 keydown和keyup 能获取所有按键,不能识别大小写 keypress 不能获取功能键,如F1 SHIFT等,能够识别大小写 文本取值: keydown和keypress:不能获取最后一个字符 keyup: 获取所有字符 如图所例,敲入ab 发生的先后顺序是 keydown,keypress,keyup keydown和keyup取到大写B的ASCII码表 66,keypress取到小写b的ASCII码表 98. keydown和keypress只能取到文本值a, keyup可以取到ab
");
window.frames["iframe_show994"].document.write(decodeHtml($("textarea#stepcodeTextarea994").val()));
window.frames["iframe_show994"].document.close();
$(window.frames["iframe_show994"]).load(function(){
$("#iframe_show994").height($("#iframe_show994").contents().find("body").height()+showittryitheight);
});
$("#iframe_show994").height($("#iframe_show994").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
var order = 0;
var clearTimer=null;
$(function(){
$("#i").keydown(function(e){
var selector = "keydown";
show(selector,e,$(this).val());
});
$("#i").keypress(function(e){
var selector = "keypress";
show(selector,e,$(this).val());
});
$("#i").keyup(function(e){
var selector = "keyup";
show(selector,e,$(this).val());
});
});
function show(selector,e,inputvalue){
clearTimeout(clearTimer);
action(selector);
key(selector,e);
value(selector,inputvalue);
clearTimer= setTimeout(clear,4000);
}
function action(selector){
$("#"+selector+"Action").css("background-color","green");
$("#"+selector+"Action").html("顺序: " + (++order ) );
}
function value(selector,value){
$("#"+selector+"Value").html(value);
}
function key(selector,e){
$("#"+selector+"Key").html(e.which);
}
function clear(){
order = 0;
$("tr#action div").css("background-color","red");
$("tr div").html("");
}
</script>
<style>
tr#action div{
border: 1px solid black;
height:50px;
background-color:red;
}
tr#value div,tr#key div{
height:50px;
background-color:#d1d1d1;
}
td{
width:25%;
}
</style>
输入框:<input id="i">
<table width="100%">
<tr>
<td></td>
<td>keydown</td>
<td>keypress</td>
<td>keyup</td>
</tr>
<tr id="action">
<td>行为</td>
<td><div id="keydownAction"></div></td>
<td><div id="keypressAction"></div></td>
<td><div id="keyupAction"></div></td>
</tr>
<tr id="key">
<td>按键</td>
<td><div id="keydownKey"></div></td>
<td><div id="keypressKey"></div></td>
<td><div id="keyupKey"></div></td>
</tr>
<tr id="value">
<td>取值</td>
<td><div id="keydownValue"></div></td>
<td><div id="keypressValue"></div></td>
<td><div id="keyupValue"></div></td>
</tr>
</table>
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
var order = 0;
var clearTimer=null;
$(function(){
$("#i").keydown(function(e){
var selector = "keydown";
show(selector,e,$(this).val());
});
$("#i").keypress(function(e){
var selector = "keypress";
show(selector,e,$(this).val());
});
$("#i").keyup(function(e){
var selector = "keyup";
show(selector,e,$(this).val());
});
});
function show(selector,e,inputvalue){
clearTimeout(clearTimer);
action(selector);
key(selector,e);
value(selector,inputvalue);
clearTimer= setTimeout(clear,4000);
}
function action(selector){
$("#"+selector+"Action").css("background-color","green");
$("#"+selector+"Action").html("顺序: " + (++order ) );
}
function value(selector,value){
$("#"+selector+"Value").html(value);
}
function key(selector,e){
$("#"+selector+"Key").html(e.which);
}
function clear(){
order = 0;
$("tr#action div").css("background-color","red");
$("tr div").html("");
}
</script>
<style>
tr#action div{
border: 1px solid black;
height:50px;
background-color:red;
}
tr#value div,tr#key div{
height:50px;
background-color:#d1d1d1;
}
td{
width:25%;
}
</style>
输入框:<input id="i">
<table width="100%">
<tr>
<td></td>
<td>keydown</td>
<td>keypress</td>
<td>keyup</td>
</tr>
<tr id="action">
<td>行为</td>
<td><div id="keydownAction"></div></td>
<td><div id="keypressAction"></div></td>
<td><div id="keyupAction"></div></td>
</tr>
<tr id="key">
<td>按键</td>
<td><div id="keydownKey"></div></td>
<td><div id="keypressKey"></div></td>
<td><div id="keyupKey"></div></td>
</tr>
<tr id="value">
<td>取值</td>
<td><div id="keydownValue"></div></td>
<td><div id="keypressValue"></div></td>
<td><div id="keyupValue"></div></td>
</tr>
</table>
");
window.frames["iframe994"].document.write(decodeHtml(code994));
window.frames["iframe994"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe994"]).load(function(){
$("#iframe994").height($("#iframe994").contents().find("body").height()+showittryitheight);
});
$("#iframe994").height($("#iframe994").contents().find("body").height()+showittryitheight);
alreadyWriteCode994 = code994;
$("#rendering994").hide();
$("#rendered994").show();
}
var tRereshRetry2DemoPanel994 = setInterval(rereshRetry2DemoPanel994,1000);
var binded994 = false;
$("textarea#stepcodeTextarea994").keyup(function(){
if(!binded994){
$(window).bind('beforeunload',function(){
binded994 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code994 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code994!=newCode){
// window.frames["iframe994"].document.write("
");
// window.frames["iframe994"].document.write(decodeHtml($("textarea#stepcodeTextarea994").val()));
// window.frames["iframe994"].document.close();
// $(window.frames["iframe994"]).load(function(){
// $("#iframe994").height($("#iframe994").contents().find("body").height()+showittryitheight);
// });
// code994 = newCode;
// }
});
$(".tryButton994").click(function(){
$("#tryDiv994").show();
$("#stepcodeTextarea994").focus();
$("#stepcodeTextarea994").height(200);
$("#iframe994").height(0);
window.frames["iframe994"].document.write("
");
window.frames["iframe994"].document.write(decodeHtml($("textarea#stepcodeTextarea994").val()));
window.frames["iframe994"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe994"]).load(function(){
$("#iframe994").height($("#iframe994").contents().find("body").height()+showittryitheight);
});
$("#iframe994").height($("#iframe994").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor994.focus();
editor994.setSize(null, "250");
$("#rendering994").hide();
$("#rendered994").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 editor994 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea994"), {
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);
}
}
});
editor994.on("change",function(doc){
if(!binded994){
$(window).bind('beforeunload',function(){
binded994 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code994 = newCode;
$("textarea#stepcodeTextarea994").val(newCode);
if(alreadyWriteCode994!=code994){
lastModifedTime994 = new Date().getTime();
$("#rendering994").show();
$("#rendered994").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor994 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor994.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv994").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
mousedown 表示鼠标按下
mouseup表示鼠标弹起
mousemove表示鼠标进入
mouseenter表示鼠标进入
mouseover表示鼠标进入
mouseleave表示鼠标离开
mouseout表示鼠标离开
进入事件有3个 mousemove mouseenter mouseover
mousemove :当鼠标进入元素,每移动一下都会被调用
mouseenter :当鼠标进入元素,调用一下,在其中移动,不调用
mouseover:当鼠标进入元素,调用一下,在其中移动,不调用
mouseenter 和 mouseover的区别
mouseenter: 当鼠标经过其子元素不会被调用
mouseover:当鼠标经过其子元素会被调用
mouseleave 和 mouseout的区别
mouseleave: 当鼠标经过其子元素不会被调用
mouseout:当鼠标经过其子元素会被调用
");
window.frames["iframe_show995"].document.write(decodeHtml($("textarea#stepcodeTextarea995").val()));
window.frames["iframe_show995"].document.close();
$(window.frames["iframe_show995"]).load(function(){
$("#iframe_show995").height($("#iframe_show995").contents().find("body").height()+showittryitheight);
});
$("#iframe_show995").height($("#iframe_show995").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#downup").mousedown(function(){
$(this).html("鼠标按下");
});
$("#downup").mouseup(function(){
$(this).html("鼠标弹起");
});
var moveNumber =0;
var enterNumber =0;
var leaveNumber =0;
var overNumber =0;
var outNumber =0;
var enterNumber1 =0;
var overNumber1 =0;
var leaveNumber1 =0;
var outNumber1 =0;
$("#move").mousemove(function(){
$("#move span.number" ).html(++moveNumber);
});
$("#enter").mouseenter(function(){
$("#enter span.number" ).html(++enterNumber);
});
$("#leave").mouseleave(function(){
$("#leave span.number" ).html(++leaveNumber);
});
$("#over").mouseover(function(){
$("#over span.number" ).html(++overNumber);
});
$("#out").mouseout(function(){
$("#out span.number" ).html(++outNumber);
});
$("#enter1").mouseenter(function(){
$("#enter1 span.number" ).html(++enterNumber1);
});
$("#over1").mouseover(function(){
$("#over1 span.number" ).html(++overNumber1);
});
$("#leave1").mouseleave(function(){
$("#leave1 span.number" ).html(++leaveNumber1);
});
$("#out1").mouseout(function(){
$("#out1 span.number" ).html(++outNumber1);
});
});
</script>
<style>
div{
background-color:pink;
margin:20px;
padding:10px;
}
.subDiv{
background-color:green;
margin:10px;
}
.parentDiv{
background-color:pink;
height:80px;
}
table{
width:100%;
border-collapse:collapse;
table-layout:fixed;
}
td{
border: 1.5px solid #d1d1d1;
vertical-align:top;
padding:20 0;
}
</style>
<table >
<tr>
<td width="100px">事件</td>
<td>效果演示</td>
</tr>
<tr>
<td>mousedown <br />
mouseup<br /></td>
<td>
<button id="downup" style="margin-left:20px">鼠标按下弹起测试</button> </td>
</tr>
<tr>
<td>mousemove<br />
mouseenter<br />
mouseover<br />
mouseleave<br />
mouseout</td>
<td>
<div id="move">mousemove 当鼠标进入元素,每移动一下都会被调用 次数<span class="number">0</span></div>
<div id="enter">mouseenter 当鼠标进入元素,调用一下,在其中移动,不调用 次数<span class="number">0</span></div>
<div id="over">mouseover 当鼠标进入元素,调用一下,在其中移动,不调用 次数<span class="number">0</span></div>
<div id="leave">mouseleave 当鼠标离开元素,调用一下 次数<span class="number">0</span></div>
<div id="out">mouseout 当鼠标离开元素,调用一下 <span class="number">0</span></div> </tr>
<tr>
<td>mouseenter<br />
mouseover</td>
<td>
<div id="enter1" class="parentDiv">
mouseenter 经过其子元素不会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div>
<div id="over1" class="parentDiv">
mouseover 经过其子元素会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div> </td>
</tr>
<tr>
<td>mouseleave<br />
mouseout </td>
<td>
<div id="leave1" class="parentDiv">
mouseleave 经过其子元素不会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div>
<div id="out1" class="parentDiv">
mouseout 经过其子元素会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div> </td>
</tr>
</table>
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#downup").mousedown(function(){
$(this).html("鼠标按下");
});
$("#downup").mouseup(function(){
$(this).html("鼠标弹起");
});
var moveNumber =0;
var enterNumber =0;
var leaveNumber =0;
var overNumber =0;
var outNumber =0;
var enterNumber1 =0;
var overNumber1 =0;
var leaveNumber1 =0;
var outNumber1 =0;
$("#move").mousemove(function(){
$("#move span.number" ).html(++moveNumber);
});
$("#enter").mouseenter(function(){
$("#enter span.number" ).html(++enterNumber);
});
$("#leave").mouseleave(function(){
$("#leave span.number" ).html(++leaveNumber);
});
$("#over").mouseover(function(){
$("#over span.number" ).html(++overNumber);
});
$("#out").mouseout(function(){
$("#out span.number" ).html(++outNumber);
});
$("#enter1").mouseenter(function(){
$("#enter1 span.number" ).html(++enterNumber1);
});
$("#over1").mouseover(function(){
$("#over1 span.number" ).html(++overNumber1);
});
$("#leave1").mouseleave(function(){
$("#leave1 span.number" ).html(++leaveNumber1);
});
$("#out1").mouseout(function(){
$("#out1 span.number" ).html(++outNumber1);
});
});
</script>
<style>
div{
background-color:pink;
margin:20px;
padding:10px;
}
.subDiv{
background-color:green;
margin:10px;
}
.parentDiv{
background-color:pink;
height:80px;
}
table{
width:100%;
border-collapse:collapse;
table-layout:fixed;
}
td{
border: 1.5px solid #d1d1d1;
vertical-align:top;
padding:20 0;
}
</style>
<table >
<tr>
<td width="100px">事件</td>
<td>效果演示</td>
</tr>
<tr>
<td>mousedown <br />
mouseup<br /></td>
<td>
<button id="downup" style="margin-left:20px">鼠标按下弹起测试</button> </td>
</tr>
<tr>
<td>mousemove<br />
mouseenter<br />
mouseover<br />
mouseleave<br />
mouseout</td>
<td>
<div id="move">mousemove 当鼠标进入元素,每移动一下都会被调用 次数<span class="number">0</span></div>
<div id="enter">mouseenter 当鼠标进入元素,调用一下,在其中移动,不调用 次数<span class="number">0</span></div>
<div id="over">mouseover 当鼠标进入元素,调用一下,在其中移动,不调用 次数<span class="number">0</span></div>
<div id="leave">mouseleave 当鼠标离开元素,调用一下 次数<span class="number">0</span></div>
<div id="out">mouseout 当鼠标离开元素,调用一下 <span class="number">0</span></div> </tr>
<tr>
<td>mouseenter<br />
mouseover</td>
<td>
<div id="enter1" class="parentDiv">
mouseenter 经过其子元素不会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div>
<div id="over1" class="parentDiv">
mouseover 经过其子元素会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div> </td>
</tr>
<tr>
<td>mouseleave<br />
mouseout </td>
<td>
<div id="leave1" class="parentDiv">
mouseleave 经过其子元素不会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div>
<div id="out1" class="parentDiv">
mouseout 经过其子元素会被调用 次数<span class="number">0</span>
<div class="subDiv">div中的子元素 </div>
</div> </td>
</tr>
</table>
");
window.frames["iframe995"].document.write(decodeHtml(code995));
window.frames["iframe995"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe995"]).load(function(){
$("#iframe995").height($("#iframe995").contents().find("body").height()+showittryitheight);
});
$("#iframe995").height($("#iframe995").contents().find("body").height()+showittryitheight);
alreadyWriteCode995 = code995;
$("#rendering995").hide();
$("#rendered995").show();
}
var tRereshRetry2DemoPanel995 = setInterval(rereshRetry2DemoPanel995,1000);
var binded995 = false;
$("textarea#stepcodeTextarea995").keyup(function(){
if(!binded995){
$(window).bind('beforeunload',function(){
binded995 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code995 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code995!=newCode){
// window.frames["iframe995"].document.write("
");
// window.frames["iframe995"].document.write(decodeHtml($("textarea#stepcodeTextarea995").val()));
// window.frames["iframe995"].document.close();
// $(window.frames["iframe995"]).load(function(){
// $("#iframe995").height($("#iframe995").contents().find("body").height()+showittryitheight);
// });
// code995 = newCode;
// }
});
$(".tryButton995").click(function(){
$("#tryDiv995").show();
$("#stepcodeTextarea995").focus();
$("#stepcodeTextarea995").height(200);
$("#iframe995").height(0);
window.frames["iframe995"].document.write("
");
window.frames["iframe995"].document.write(decodeHtml($("textarea#stepcodeTextarea995").val()));
window.frames["iframe995"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe995"]).load(function(){
$("#iframe995").height($("#iframe995").contents().find("body").height()+showittryitheight);
});
$("#iframe995").height($("#iframe995").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor995.focus();
editor995.setSize(null, "250");
$("#rendering995").hide();
$("#rendered995").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 editor995 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea995"), {
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);
}
}
});
editor995.on("change",function(doc){
if(!binded995){
$(window).bind('beforeunload',function(){
binded995 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code995 = newCode;
$("textarea#stepcodeTextarea995").val(newCode);
if(alreadyWriteCode995!=code995){
lastModifedTime995 = new Date().getTime();
$("#rendering995").show();
$("#rendered995").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor995 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor995.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv995").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show992"].document.write(decodeHtml($("textarea#stepcodeTextarea992").val()));
window.frames["iframe_show992"].document.close();
$(window.frames["iframe_show992"]).load(function(){
$("#iframe_show992").height($("#iframe_show992").contents().find("body").height()+showittryitheight);
});
$("#iframe_show992").height($("#iframe_show992").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("input").focus(function(){
$(this).val("获取了焦点");
});
$("input").blur(function(){
$(this).val("失去了焦点");
});
});
</script>
<style>
</style>
<input type="text" >
<input type="text" >
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("input").focus(function(){
$(this).val("获取了焦点");
});
$("input").blur(function(){
$(this).val("失去了焦点");
});
});
</script>
<style>
</style>
<input type="text" >
<input type="text" >
");
window.frames["iframe992"].document.write(decodeHtml(code992));
window.frames["iframe992"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe992"]).load(function(){
$("#iframe992").height($("#iframe992").contents().find("body").height()+showittryitheight);
});
$("#iframe992").height($("#iframe992").contents().find("body").height()+showittryitheight);
alreadyWriteCode992 = code992;
$("#rendering992").hide();
$("#rendered992").show();
}
var tRereshRetry2DemoPanel992 = setInterval(rereshRetry2DemoPanel992,1000);
var binded992 = false;
$("textarea#stepcodeTextarea992").keyup(function(){
if(!binded992){
$(window).bind('beforeunload',function(){
binded992 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code992 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code992!=newCode){
// window.frames["iframe992"].document.write("
");
// window.frames["iframe992"].document.write(decodeHtml($("textarea#stepcodeTextarea992").val()));
// window.frames["iframe992"].document.close();
// $(window.frames["iframe992"]).load(function(){
// $("#iframe992").height($("#iframe992").contents().find("body").height()+showittryitheight);
// });
// code992 = newCode;
// }
});
$(".tryButton992").click(function(){
$("#tryDiv992").show();
$("#stepcodeTextarea992").focus();
$("#stepcodeTextarea992").height(200);
$("#iframe992").height(0);
window.frames["iframe992"].document.write("
");
window.frames["iframe992"].document.write(decodeHtml($("textarea#stepcodeTextarea992").val()));
window.frames["iframe992"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe992"]).load(function(){
$("#iframe992").height($("#iframe992").contents().find("body").height()+showittryitheight);
});
$("#iframe992").height($("#iframe992").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor992.focus();
editor992.setSize(null, "250");
$("#rendering992").hide();
$("#rendered992").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 editor992 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea992"), {
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);
}
}
});
editor992.on("change",function(doc){
if(!binded992){
$(window).bind('beforeunload',function(){
binded992 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code992 = newCode;
$("textarea#stepcodeTextarea992").val(newCode);
if(alreadyWriteCode992!=code992){
lastModifedTime992 = new Date().getTime();
$("#rendering992").show();
$("#rendered992").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor992 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor992.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv992").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
change() 内容改变
注: 对于文本框,只有当该文本失去焦点的时候,才会触发change事件。
");
window.frames["iframe_show993"].document.write(decodeHtml($("textarea#stepcodeTextarea993").val()));
window.frames["iframe_show993"].document.close();
$(window.frames["iframe_show993"]).load(function(){
$("#iframe_show993").height($("#iframe_show993").contents().find("body").height()+showittryitheight);
});
$("#iframe_show993").height($("#iframe_show993").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#input1").change(function(){
var text = $(this).val();
$("#message").html("input1的内容变为了"+text);
});
});
</script>
<style>
</style>
<div id="message"></div>
<input id="input1" type="text" >
<br>
<input size="50" id="input2"type="text" value="只有当input1失去焦点的时候,才会触发change事件" >
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#input1").change(function(){
var text = $(this).val();
$("#message").html("input1的内容变为了"+text);
});
});
</script>
<style>
</style>
<div id="message"></div>
<input id="input1" type="text" >
<br>
<input size="50" id="input2"type="text" value="只有当input1失去焦点的时候,才会触发change事件" >
");
window.frames["iframe993"].document.write(decodeHtml(code993));
window.frames["iframe993"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe993"]).load(function(){
$("#iframe993").height($("#iframe993").contents().find("body").height()+showittryitheight);
});
$("#iframe993").height($("#iframe993").contents().find("body").height()+showittryitheight);
alreadyWriteCode993 = code993;
$("#rendering993").hide();
$("#rendered993").show();
}
var tRereshRetry2DemoPanel993 = setInterval(rereshRetry2DemoPanel993,1000);
var binded993 = false;
$("textarea#stepcodeTextarea993").keyup(function(){
if(!binded993){
$(window).bind('beforeunload',function(){
binded993 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code993 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code993!=newCode){
// window.frames["iframe993"].document.write("
");
// window.frames["iframe993"].document.write(decodeHtml($("textarea#stepcodeTextarea993").val()));
// window.frames["iframe993"].document.close();
// $(window.frames["iframe993"]).load(function(){
// $("#iframe993").height($("#iframe993").contents().find("body").height()+showittryitheight);
// });
// code993 = newCode;
// }
});
$(".tryButton993").click(function(){
$("#tryDiv993").show();
$("#stepcodeTextarea993").focus();
$("#stepcodeTextarea993").height(200);
$("#iframe993").height(0);
window.frames["iframe993"].document.write("
");
window.frames["iframe993"].document.write(decodeHtml($("textarea#stepcodeTextarea993").val()));
window.frames["iframe993"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe993"]).load(function(){
$("#iframe993").height($("#iframe993").contents().find("body").height()+showittryitheight);
});
$("#iframe993").height($("#iframe993").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor993.focus();
editor993.setSize(null, "250");
$("#rendering993").hide();
$("#rendered993").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 editor993 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea993"), {
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);
}
}
});
editor993.on("change",function(doc){
if(!binded993){
$(window).bind('beforeunload',function(){
binded993 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code993 = newCode;
$("textarea#stepcodeTextarea993").val(newCode);
if(alreadyWriteCode993!=code993){
lastModifedTime993 = new Date().getTime();
$("#rendering993").show();
$("#rendered993").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor993 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor993.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv993").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show998"].document.write(decodeHtml($("textarea#stepcodeTextarea998").val()));
window.frames["iframe_show998"].document.close();
$(window.frames["iframe_show998"]).load(function(){
$("#iframe_show998").height($("#iframe_show998").contents().find("body").height()+showittryitheight);
});
$("#iframe_show998").height($("#iframe_show998").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<form id="form" action="http://127.0.0.1/study/login.jsp">
账号 : <input name="name" type=""> <br>
密码: <input name="password" type=""><br>
<input type="submit" value="登陆">
</form>
<script>
$(function(){
$("#form").submit(function(){
alert("提交账号密码");
});
});
</script>
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<form id="form" action="http://127.0.0.1/study/login.jsp">
账号 : <input name="name" type=""> <br>
密码: <input name="password" type=""><br>
<input type="submit" value="登陆">
</form>
<script>
$(function(){
$("#form").submit(function(){
alert("提交账号密码");
});
});
</script>
");
window.frames["iframe998"].document.write(decodeHtml(code998));
window.frames["iframe998"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe998"]).load(function(){
$("#iframe998").height($("#iframe998").contents().find("body").height()+showittryitheight);
});
$("#iframe998").height($("#iframe998").contents().find("body").height()+showittryitheight);
alreadyWriteCode998 = code998;
$("#rendering998").hide();
$("#rendered998").show();
}
var tRereshRetry2DemoPanel998 = setInterval(rereshRetry2DemoPanel998,1000);
var binded998 = false;
$("textarea#stepcodeTextarea998").keyup(function(){
if(!binded998){
$(window).bind('beforeunload',function(){
binded998 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code998 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code998!=newCode){
// window.frames["iframe998"].document.write("
");
// window.frames["iframe998"].document.write(decodeHtml($("textarea#stepcodeTextarea998").val()));
// window.frames["iframe998"].document.close();
// $(window.frames["iframe998"]).load(function(){
// $("#iframe998").height($("#iframe998").contents().find("body").height()+showittryitheight);
// });
// code998 = newCode;
// }
});
$(".tryButton998").click(function(){
$("#tryDiv998").show();
$("#stepcodeTextarea998").focus();
$("#stepcodeTextarea998").height(200);
$("#iframe998").height(0);
window.frames["iframe998"].document.write("
");
window.frames["iframe998"].document.write(decodeHtml($("textarea#stepcodeTextarea998").val()));
window.frames["iframe998"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe998"]).load(function(){
$("#iframe998").height($("#iframe998").contents().find("body").height()+showittryitheight);
});
$("#iframe998").height($("#iframe998").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor998.focus();
editor998.setSize(null, "250");
$("#rendering998").hide();
$("#rendered998").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 editor998 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea998"), {
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);
}
}
});
editor998.on("change",function(doc){
if(!binded998){
$(window).bind('beforeunload',function(){
binded998 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code998 = newCode;
$("textarea#stepcodeTextarea998").val(newCode);
if(alreadyWriteCode998!=code998){
lastModifedTime998 = new Date().getTime();
$("#rendering998").show();
$("#rendered998").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor998 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor998.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv998").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
以上所有的事件处理,都可以通过on() 绑定事件来处理 $("selector").on("event",function);
");
window.frames["iframe_show3006"].document.write(decodeHtml($("textarea#stepcodeTextarea3006").val()));
window.frames["iframe_show3006"].document.close();
$(window.frames["iframe_show3006"]).load(function(){
$("#iframe_show3006").height($("#iframe_show3006").contents().find("body").height()+showittryitheight);
});
$("#iframe_show3006").height($("#iframe_show3006").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#b").on("click",function(){
$("#message").html("单击按钮");
});
$("#b").on("dblclick",function(){
$("#message").html("双击按钮");
});
});
</script>
<div id="message"></div>
<button id="b">测试单击和双击</button>
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#b").on("click",function(){
$("#message").html("单击按钮");
});
$("#b").on("dblclick",function(){
$("#message").html("双击按钮");
});
});
</script>
<div id="message"></div>
<button id="b">测试单击和双击</button>
");
window.frames["iframe3006"].document.write(decodeHtml(code3006));
window.frames["iframe3006"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3006"]).load(function(){
$("#iframe3006").height($("#iframe3006").contents().find("body").height()+showittryitheight);
});
$("#iframe3006").height($("#iframe3006").contents().find("body").height()+showittryitheight);
alreadyWriteCode3006 = code3006;
$("#rendering3006").hide();
$("#rendered3006").show();
}
var tRereshRetry2DemoPanel3006 = setInterval(rereshRetry2DemoPanel3006,1000);
var binded3006 = false;
$("textarea#stepcodeTextarea3006").keyup(function(){
if(!binded3006){
$(window).bind('beforeunload',function(){
binded3006 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code3006 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code3006!=newCode){
// window.frames["iframe3006"].document.write("
");
// window.frames["iframe3006"].document.write(decodeHtml($("textarea#stepcodeTextarea3006").val()));
// window.frames["iframe3006"].document.close();
// $(window.frames["iframe3006"]).load(function(){
// $("#iframe3006").height($("#iframe3006").contents().find("body").height()+showittryitheight);
// });
// code3006 = newCode;
// }
});
$(".tryButton3006").click(function(){
$("#tryDiv3006").show();
$("#stepcodeTextarea3006").focus();
$("#stepcodeTextarea3006").height(200);
$("#iframe3006").height(0);
window.frames["iframe3006"].document.write("
");
window.frames["iframe3006"].document.write(decodeHtml($("textarea#stepcodeTextarea3006").val()));
window.frames["iframe3006"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3006"]).load(function(){
$("#iframe3006").height($("#iframe3006").contents().find("body").height()+showittryitheight);
});
$("#iframe3006").height($("#iframe3006").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor3006.focus();
editor3006.setSize(null, "250");
$("#rendering3006").hide();
$("#rendered3006").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 editor3006 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3006"), {
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);
}
}
});
editor3006.on("change",function(doc){
if(!binded3006){
$(window).bind('beforeunload',function(){
binded3006 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code3006 = newCode;
$("textarea#stepcodeTextarea3006").val(newCode);
if(alreadyWriteCode3006!=code3006){
lastModifedTime3006 = new Date().getTime();
$("#rendering3006").show();
$("#rendered3006").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor3006 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor3006.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv3006").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
触发事件,在本例中,文档加载好之后,就触发dblclick双击事件,而不是通过去手动双击。 $("selector").trigger("event");
");
window.frames["iframe_show3007"].document.write(decodeHtml($("textarea#stepcodeTextarea3007").val()));
window.frames["iframe_show3007"].document.close();
$(window.frames["iframe_show3007"]).load(function(){
$("#iframe_show3007").height($("#iframe_show3007").contents().find("body").height()+showittryitheight);
});
$("#iframe_show3007").height($("#iframe_show3007").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#b").on("click",function(){
$("#message").html("单击按钮");
});
$("#b").on("dblclick",function(){
$("#message").html("双击按钮");
});
$("#b").trigger("dblclick");
});
</script>
<div id="message"></div>
<button id="b">测试单击和双击</button>
<script src="http://127.0.0.1/study/jquery.min.js"></script>
<script>
$(function(){
$("#b").on("click",function(){
$("#message").html("单击按钮");
});
$("#b").on("dblclick",function(){
$("#message").html("双击按钮");
});
$("#b").trigger("dblclick");
});
</script>
<div id="message"></div>
<button id="b">测试单击和双击</button>
");
window.frames["iframe3007"].document.write(decodeHtml(code3007));
window.frames["iframe3007"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3007"]).load(function(){
$("#iframe3007").height($("#iframe3007").contents().find("body").height()+showittryitheight);
});
$("#iframe3007").height($("#iframe3007").contents().find("body").height()+showittryitheight);
alreadyWriteCode3007 = code3007;
$("#rendering3007").hide();
$("#rendered3007").show();
}
var tRereshRetry2DemoPanel3007 = setInterval(rereshRetry2DemoPanel3007,1000);
var binded3007 = false;
$("textarea#stepcodeTextarea3007").keyup(function(){
if(!binded3007){
$(window).bind('beforeunload',function(){
binded3007 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code3007 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code3007!=newCode){
// window.frames["iframe3007"].document.write("
");
// window.frames["iframe3007"].document.write(decodeHtml($("textarea#stepcodeTextarea3007").val()));
// window.frames["iframe3007"].document.close();
// $(window.frames["iframe3007"]).load(function(){
// $("#iframe3007").height($("#iframe3007").contents().find("body").height()+showittryitheight);
// });
// code3007 = newCode;
// }
});
$(".tryButton3007").click(function(){
$("#tryDiv3007").show();
$("#stepcodeTextarea3007").focus();
$("#stepcodeTextarea3007").height(200);
$("#iframe3007").height(0);
window.frames["iframe3007"].document.write("
");
window.frames["iframe3007"].document.write(decodeHtml($("textarea#stepcodeTextarea3007").val()));
window.frames["iframe3007"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe3007"]).load(function(){
$("#iframe3007").height($("#iframe3007").contents().find("body").height()+showittryitheight);
});
$("#iframe3007").height($("#iframe3007").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor3007.focus();
editor3007.setSize(null, "250");
$("#rendering3007").hide();
$("#rendered3007").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 editor3007 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3007"), {
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);
}
}
});
editor3007.on("change",function(doc){
if(!binded3007){
$(window).bind('beforeunload',function(){
binded3007 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code3007 = newCode;
$("textarea#stepcodeTextarea3007").val(newCode);
if(alreadyWriteCode3007!=code3007){
lastModifedTime3007 = new Date().getTime();
$("#rendering3007").show();
$("#rendered3007").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor3007 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor3007.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv3007").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|