English 中文(简体)
动态表格
原标题:dynamic table jquery

想有一个充满活力的桌子,分数不一,取决于有多少数据能够显示我。 我尝试了,但我的代码只增加了一条线,我不知道如何增加两条线,因此每行都有用户名栏和用户地址栏。

$(document).ready( function(){
 $("#getdata").click(function () {
     var value1=$("#user_name").val();   
          $("#tr1").append(value1);    
var value2=$("#user_address").val();  
          $("#tr2").append(value2); 
           value1.append(value2)})})

我认为,我需要做的是说明数据数量和tr子如何,但Iam没有确定如何做到这一点。

Thank in advance LS

问题回答

I think what you are looking for is this.

原文

var $table  = $("#tblData");
var $userName = $("#userName");
var $userAddress = $("#userAddress");
$("#btnAdd").click(function(){
    $table.append("<tr><td>"+ $userName.val() +"</td><td>"+ $userAddress.val() +"</td></tr>")
    $userName.val("");
    $userAddress.val("");
});

您可以添加一个验证,以核实用户名称和地址是否均由用户输入。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签