11.7-2017复习总结杂

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了11.7-2017复习总结杂相关的知识,希望对你有一定的参考价值。

1
img=document.createElement("img");
就相当于html中的<img> 创建了这样一个对象


举个例子:

如果是相对整个窗口的坐标的话可以这样写
var x = "100px", y = "100px";
var img = document.createElement( "img" );
document.body.appendChild( img );
image.style.position = "absolute";
image.style.left = x;
image.style.top = y;
这个图片就会显示在窗口左上角坐标(100,100)处


总结:document.createElement("标签元素");-----创建新的标签元素;
document.createAttribute("元素name")----创建新的属性;
document.createComment("注释 ");---------创建新的comment(注释);
document.createTextNode(""); -------------创建新的文本;
创建文本 eg:
function myFunction(){
var h=document.createElement("H1");
var t=document.createTextNode("Hello World");
h.appendChild(t);
document.body.appendChild(h);
};
2

 


----HTML 中:
<element onmouseup="SomejavascriptCode">
----JavaScript 中:
object.onmouseup=function(){SomeJavaScriptCode};

鼠标事件 -DOM-event


提示: 与 onmouseup 事件相关联的事件触发次序 (左边/中间 鼠标按钮):
onmousedown
onmouseup
onclick
与 onmouseup 事件相关联的事件触发次序 (右边鼠标按钮):
onmousedown
onmouseup
oncontextmenu

 

监听事件
eg:addEventListener属性
<script>
document.getElementById("fname").addEventListener("focus", myFunction);
function myFunction() {
document.getElementById("fname").style.backgroundColor = "red";
}
</script>
表单事件:
onfocusin 事件在一个元素即将获得焦点时触发。
提示: onfocusin 事件类似于 onfocus 事件。 主要的区别是 onfocus 事件不支持冒泡。
因此,如果你想知道元素或者其子元素是否获取焦点,需要使用 onfocusin 事件。
onfocusout

 

oninput 事件在用户输入时触发。
该事件在 <input> 或 <textarea> 元素的值发生改变时触发。
提示: 该事件类似于 onchange 事件。不同之处在于 oninput 事件在元素值发生变化是立即触发, onchange 在元素失去焦点时触发。
另外一点不同是 onchange 事件也可以作用于 <keygen> 和 <select> 元素。

onsearch 事件在用户按下"ENTER(回车)" 按键或点击 type="search" 的 <input> 元素的 "x(搜索)" 按钮时触发。


剪贴板事件:


属性 描述
oncopy 该事件在用户拷贝元素内容时触发
oncut 该事件在用户剪切元素内容时触发
onpaste 该事件在用户粘贴元素内容时触发


---------发现了小问题当内容没有被选中,也是以发生以上事件


打印事件

onafterprintprint///onbeforeprint


提示: 快捷键,如 Ctrl+P 可以设置页面打印。

 


拖动事件(HTML5Z中的常见属性)

 


3
提示:Document 对象是 Window 对象的一部分,可通过 window.document 属性对其进行访问。

document.addEventListener() 方法用于向文档添加事件句柄。
提示: 可以使用 document.removeEventListener() 方法来移除 addEventListener() 方法添加的事件句柄。
提示:使用 element.addEventListener() 方法为指定元素添加事件句柄。

 

4
preventDefault() 方法阻止元素发生默认的行为(例如,当点击提交按钮时阻止对表单的提交)。
$("a").click(function(event){
event.preventDefault();
});



































































以上是关于11.7-2017复习总结杂的主要内容,如果未能解决你的问题,请参考以下文章

2111 JAVASE每日复习总结 链接汇总

2107 JAVASE每日复习总结 链接汇总

2110 JAVASE每日复习总结 链接汇总

一周复习总结第二周

2108 JAVASE每日复习总结 链接汇总

2109 JAVASE每日复习总结 链接汇总