2734156755z

全局变量 event才是事件对象

js和jquery    操作元素  差别在DOM操作

找元素

js   document.getElementById();

     document.getElementByTagName();

jquery  .one

     $(选择器)  $(\'img\')

js对象  jsobj    jquery对象 jqobj

操作内容

    js 

非表单元素      jsobj.innerHTML           jsobj

表单元素        jsobj.value

jquery

 非表单    jqobj.html()     jqobj.html(\'123\')

表单元素  jqobj.val()       jqobj.val("123")

操作属性

js

   jsobj.getAttribute("class");

   jsobj.setAttribute("class","add")

   jsobj.removeAttribute("class")

jquery

  jqobj.attr(\'class\',\'add\');一个参数是获取   两个参数是设置

 jqobj.attr({\'class\':\'add\',\'id\':\'id\'});同时设置多个属性  用json格式数据

 jqobj.removeAttr()

jqobj.addClass(\'add\');

操作样式

js   

   jsobj.style.color="red";

jquery

   jqobj.css();

操作事件

js

   jsobj.onclick=function(){}

jquery

   jqobj.click(function(){})

添加删除元素 

 jqobj.html(\'<button></button>\')

页面加载完成

jquery

方法一

    $(document).ready(function(){

     })

方法二

    $(function(){

     })

分类:

技术点:

相关文章:

猜你喜欢
相关资源
相似解决方案