zoukankan      html  css  js  c++  java
  • jquery调用javascript方法

    本来想找个“优雅”一点的方法,类似C#在调用C++方法时候的Invoke之类的。没找到,后来想想,其实也没必要,直接写就好了,算最优雅了吧。只是少了VS的Intelligence,有点不习惯罢了。

    事情起因:

    想写个带类似treeview功能的table,用的是jquey.load 方法,事件complete的时候想把row append到当前行下面,但失败了,有个语法错误。暂不晓得怎么改。后来网上找到其实Html的table对象本来就有这样的方法,

    HTMLTableElement.insertRow();

    语法:

    var row = HTMLTableElement.insertRow(optional index = -1);

    row是一个HTMLTableRowElement对象。

    具体例子看看这个吧:

    <table id="TableA">
    <tr>
    <td>Old top row</td>
    </tr>
    </table>
    <script type="text/javascript">
    
    function addRow(tableID) {
      // Get a reference to the table
      var tableRef = document.getElementById(tableID);
    
      // Insert a row in the table at row index 0
      var newRow   = tableRef.insertRow(0);
    
      // Insert a cell in the row at index 0
      var newCell  = newRow.insertCell(0);
    
      // Append a text node to the cell
      var newText  = document.createTextNode('New top row');
      newCell.appendChild(newText);
    }
    
    // Call addRow() with the ID of a table
    addRow('TableA');
    
    </script>
    View Code
  • 相关阅读:
    python input函数
    linux可用内存判断
    python if-elif-else 判断
    python if判断
    python使用range()函数创建数字列表list
    python range函数
    python语法缩进
    python for循环
    python列表删除和排序
    hbctf 父亲的信
  • 原文地址:https://www.cnblogs.com/sheldon-lou/p/3952977.html
Copyright © 2011-2022 走看看