zoukankan      html  css  js  c++  java
  • 开发跨浏览器的JavaScript

    最近,看了AJAX的开发基础这本书.发现有几行代码对我们编程也有好处.具体如下 :

    1向表中追加行
    2通过JAVASCRIPT设置元素的样式
    3设置元素的CLASS属性
    4创建输入元素
    5向输入元素增加事件处理程序
    6创建单选按钮

    1<table id="MyTable>
    <tbody id="MyTableBody"></tbody>
    </table>
    var cell = documentcreateElement("td").appendChild(document.createTextNode("foo"));
    var row = document.createElement("tr").appendChild(cell);
    document.getElementById("MyTableBoyd").appendChild(row);


    2
    var spanElement = document.getElementById("myspan");
    //spanElement.setAttribute("style","font-weight:bold;color:red");
    spanElement.style.cssText="font-weight:bold;color:red";

    3
    element.setAttribute("class","stylename");
    element.setAttribute("classname","stylename");//IE

    4创建输入元素
    var button = document.createElement("input");
    button.setAttribute("type","button");
    document.getElementById("form").appendChild(button);

    5
    var element = document.getElementById("ee");
    element.onclick=function(){todo();};

    6
    var ration = document.createElement("<input type='radio' name='radioa' value='checked'>);//ie

    vat radion = document.createElement("input");
    radion .setAttribute("type","radio");
    radion.setAttribute("name","radionsss");
    radion.setAttribute("value","checked");


    另外,判定IE是不是:if(document.uniqueID)如果为TRUE,IE,否则是非IE
  • 相关阅读:
    情感成本
    已知二叉树前序和中序,求后序
    贫穷的本质
    Centos安装docker及常见docker容器创建脚本
    SpringBoot与SpringCloud对应版本及官方查询方法
    工作流
    Host 'xxx' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
    list_layout.ini说明
    layout.ini说明
    config.ini说明
  • 原文地址:https://www.cnblogs.com/DaiWei/p/359389.html
Copyright © 2011-2022 走看看