Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Merge Multiple Tables into a Single Table in JavaScript

Sep 13, 2013
Introduction

Here I will explain how to use
jQuery to merge multiple tables into a single table in Javascript or jQuery to merge two tables into single table.


To merge two tables into single table we need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Merge Multiple Tables into single table in webpage</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$('#btnMerge').click(function() {
$('#tbl1 > tbody:last').append($('#tbl2 > tbody').html());
$('#tbl2').remove();
})
})
</script>
</head>
<body>
<div>
<table id="tbl1" border="1" cellspacing="1">
<tr>
<td><b>UserName</b></td><td><b>Education</b></td><td><b>Location</b></td>
</tr>
<tr>
<td>Suresh</td><td>B.Tech</td><td>Chennai</td>
</tr>
<tr>
<td>Rohini</td><td>M.Sc</td><td>Chennai</td>
</tr>
<tr>
<td>Mahesh</td><td>Phd</td><td>Delhi</td>
</tr>
<tr>
<td>Madhav</td><td>MBBS</td><td>Nagpur</td>
</tr>
</table>
<table id="tbl2" border="1" cellspacing="1">
<tr>
<td>Suresh</td><td>B.Tech</td><td>Chennai</td>
</tr>
<tr>
<td>Rohini</td><td>M.Sc</td><td>Chennai</td>
</tr>
<tr>
<td>Mahesh</td><td>Phd</td><td>Delhi</td>
</tr>
<tr>
<td>Madhav</td><td>MBBS</td><td>Nagpur</td>
</tr>
</table>
<input type="button" id="btnMerge" value="Merge Tables" />
</div>
</body>
</html>
Demo


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Manish said...

Never even thought about doing it with JQuery.. Its blowing my mind right now. Awesome!!!

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.