table指定位置添加行
<html>
<head>
<script type="text/javascript">
//global var
var pos =
//to find the position you mouse has pressed
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == ) // defeat Safari bug
targ = targ.parentNode
if(targ.tagName=="TD"){//to adjust whether the element is tabledata
pos = targ.parentNode.rowIndex+
}
else if(targ.tagName=="INPUT"){
//to do nothing
} else{
pos =
}
//alert(pos)
}
//to insert a row in the place
function insRow()
{
//alert(pos)
var x=document.getElementById('myTable').insertRow(pos)
var y=x.insertCell()
var z=x.insertCell()
y.innerHTML=document.getElementById("cell1").value
z.innerHTML=document.getElementById("cell2").value
}
</script>
</head>
<body onmousedown="whichElement(event)">
<table id="myTable" border="">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
<tr>
<td>Row3 cell1</td>
<td>Row3 cell2</td>
</tr>
</table> <p>
Cell1:<input type="text" id= "cell1" value="cell1"/>
Cell2:<input type="text" id= "cell2" value="cell2"/>
</p>
<input type="button" onclick="insRow()" value="插入行">
</body>
</html>
欢迎评论。。。。让我看到你的反馈。。。。
table指定位置添加行的更多相关文章
- js在table指定tr行上或底下添加tr行
js在table指定tr行上或下面添加tr行 function onAddTR(trIndex) { var tb = document.getElementB ...
- Aspose.Words 将word2中的内容插入到word1中的指定位置
将word2中的内容插入到word1中的指定位置(经测试可用) 在官网找到的例子,记录一下: public static void InsertDocumentAtBookmark(string da ...
- java POI往word文档中指定位置插入表格
1.Service demo import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.a ...
- 在word中的表格指定位置插入一行
//创建一个Document类对象,并加载Word文档 Document doc = new Document(); doc.LoadFromFile(@"C:\Users\Administ ...
- vbscript input select 添加个option根据value值到指定位置--相当于排序
'添加option到指定位置(按value排序) dim valindex valindex=-1 for i=0 to selcom.length-1 if selcom.Options(i).va ...
- 横向滑动的HorizontalListView滑动指定位置的解决方法
项目中用到了自定义横向滑动的控件:HorizontalListView,点击其中一项,跳转到另外一个大图界面,大图界面也是HorizontalListView,想使用setSelection方法设定 ...
- shell如何在指定文件的指定位置后面添加内容
最近工作中遇到一个问题,想在某个文件的指定位置后面添加一个标志位,要求在shell脚本里实现. 问题说明: 想在sys_config.fex文本的某个字符串后面添加一个flag 例如:sys_conf ...
- jQuery滚动条回到顶部或指定位置
jQuery滚动条回到顶部或指定位置 在很多网站,为了增强用户体验,我们会看到回到顶部的按钮,不用手动拖拽滚动条就能回到顶部,非常方便.下面就介绍用jquery实现的滚动到顶部的代码 $(functi ...
- 使用C语言在Win控制台中实现指定位置输出
在古老的Turbo C中有个GotoXY可以让你在指定坐标中输出文字,可恨的是我看过的C语言书籍,有一半都是关于它的.我现在用着Windows系统,不可能还让我去写着DOS程序啊,起码也得从Win控制 ...
随机推荐
- 安卓MonkeyRunner源码分析之工作原理架构图及系列集合
花了点时间整理了下MonkeyRunner的工作原理图,请配合本人博客里面MonkeyRunner其他源码分析文章进行阅读.下面整理成相应系列列表方便大家阅读: MonkeyRunner源码分析之-谁 ...
- CORS跨域资源共享
CORS(跨域资源共享)跨域问题及解决 当使用ajax跨域请求时,浏览器报错:XmlHttpRequest error: Origin null is not allowed by Access-Co ...
- Serv-U执行CMD命令
site exec + 命令.比如关机: site exec shutdown -r -t 0 注意,网上很多教程在前面加了一个“quote”,实测根本无效,不知道那些教材是怎么回事. 执行方式有很多 ...
- SQL点滴8—the account is currently locked out. The system administrator can unlock it.
原文:SQL点滴8-the account is currently locked out. The system administrator can unlock it. 今天遇到的问题比较有意思. ...
- 快速构建Windows 8风格应用36-商店应用发布流程
原文:快速构建Windows 8风格应用36-商店应用发布流程 引言 在发布应用之前,我们需要注册开发者账号才能够发布应用.我们可以登录https://appdev.microsoft.com/Sto ...
- Ora中select某时间段记录sql语句
要查找某时间段的记录,例如查找2013-11-1到2013-11-30的记录. ' group by user_name, user_id 注意:SQL语句中含有sum累加函数,末尾要加group b ...
- Mysql高级之索引
原文:Mysql高级之索引 索引:是针对数据所建立的目录. 作用: 可以加快查询速度 负面影响: 降低了增删改的速度. 索引的创建原则: 1:不要过度索引 2:在where条件最频繁的列上加.在重复度 ...
- Mocha JavaScript TDD
JavaScript TDD with Mocha 2014-04-30 02:05 by owenyang, 317 阅读, 0 评论, 收藏, 编辑 开发现状 当新的版本快要发布的时候,大家都忙于 ...
- WebApi HttpMsgHanler的执行顺序
原来忘记在哪个大牛的博客上看到的,说添加顺序与执行顺序是相反的,事实在下边:直接上代码: //STEP10,不论如何先记录下来请求信息 if (msgHandlerSettings.LoggingHa ...
- 在一般处理文件中访问Session需要添加IRequiresSessionState
在IHttpHandler 使用Session 通常我们经常,通过session判定用户是否登录.还有一些临时的.重要的数据也尝尝存放在Session中. 在页面我们很容易的得到Session的值,但 ...