jquery的应用和JS的区别

jquery 和 js的主要区别在于DOM操作

DOM操作:

找元素:
js:
document.getElementBy(ID,classnama,tagname)
jquery:
$(选择器)
例:$(.one)
操作内容:
js:
非表单: Dom.innerHTML
表单:Dom.value
jquery:
非表单: jqDom.html(str)
表单:jqDom.val(str)
操作属性:
js:
设置: Dom.setAttribute("","");
获取:Dom.getAttribute("");
jquery:
设置: jq.arr();
获取:jq.arr("");操作一个是获取
jq.arr("","");操作两个是设置
jq.arr({
"属性名1":"属性值1",
"属性名2":"属性值2",
... 设置多个属性
});
操作样式:
js:
Dom.style.color
jquery:
jq.css();jq.css("");

添加多个样式: jq.css({
"":"",
"":"",
....
})
操作事件:
js:
Dom.addEventListener("click",事件名);
Dom.addEventListener("",);
Dom.addEventListener("",);
移除事件:
Dom.removeEventListener("",);
jquery:
jqDom.cick(function(){
隐藏事件:
jqDom.bind("click",show())  

bind() 方法为被选元素添加一个或多个事件处理程序,并规定事件发生时运行的函数。
移除事件:
jqDom.unbind("click",show())

})

知识点:
1.jQuery转 dom 对象
$()[0] 或者 $().get(0)
2.dom对象转jQuery对象数组取值
$().eq(0)

原文地址:https://www.cnblogs.com/sc1314-1218/p/8487206.html