使用jQuery添加行 [英] Add row using jquery

查看:76
本文介绍了使用jQuery添加行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在打印ID为'contactlist1','contactlist2','contactlist3'...的行.我已经根据数据库中存储的值完成了此操作.现在,我想使用jquery在按钮单击事件上添加ID为"contactlist4","contactlist5"的更多行.尽管我已经根据表中的数据库获取了要打印的变量的值.现在,我想在该ID旁边添加行...

I am printing a row with id as 'contactlist1', 'contactlist2', 'contactlist3'.... I have done this according to values stored in database. Now I want to add more row with id 'contactlist4', 'contactlist5', on button click event using jquery. Though I have taken values of variables that I am printing according to database in table. Now I wish to add row next to that id...

<tr id='contactlist1'>
<tr id='contactlist2'>

我想为使用命令的行添加<tr id='contactlist3'>

I want to add row as <tr id='contactlist3'> for that I have used command

$("#contactlist" + k ).after(newRow);
k++;

k的值3是我接受的变量.这是将ID表示为'contactlist3'

k has value 3 that I have taken in variable. Is this correct to way to present id as 'contactlist3'

推荐答案

工作正常.还有其他问题.也许在您运行迭代器时尚未包含jQuery或不准备将jQuery用于文档?

It works fine. Something else is going wrong. Perhaps jQuery isn't included or ready for the document by the time you're running your iterator?

http://jsfiddle.net/4JWPf/

这篇关于使用jQuery添加行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆