window.onload = function () {
var oDiv = document.getElementById('div1');
var oBtn = document.getElementById('btn1');
//oBtn.onclick = function () {
oBtn.onclick = function (ev) {
// (ev)是事件的参数。函数里有 oEvent这个变量,所以function () 括号内要写参数。
var oEvent = ev || event;
oDiv.style.display = 'block';
oEvent.cancelBubble = true;
};
document.onclick = function () {
oDiv.style.display = 'none';
}
}
window.onload = function () {
var oTxt1 = document.getElementById('txt1');
var oTxt2 = document.getElementById('txt2');
var oBtn = document.getElementById('btn1');
oBtn.onclick = function(){
oTxt2.value += oTxt1.value + '
'; // 符号是反向的,和注释相反的那个。
// oTxt2.value = oTxt1.value + oTxt2.value;
oTxt1.value = '';
};
document.onkeydown = function(ev){
var oEvent = ev || event;
if(oEvent.keyCode==13) //keycode keyCode C大写
//if(oEvent.keyCode==13 && oEvent.ctrlKey) // ctrl+Enter
{
oTxt2.value += oTxt1.value + '
';
oTxt1.value = '';
}
}
}