前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jquery调用javascript方法

jquery调用javascript方法

作者头像
_淡定_
发布2018-08-24 12:03:08
1.6K0
发布2018-08-24 12:03:08
举报
文章被收录于专栏:dotnet & java

本来想找个“优雅”一点的方法,类似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对象。

具体例子看看这个吧:

代码语言:javascript
复制
<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>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014-09-03 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档