<table> //big table
<tr >
<td></td><td></td><td></td><td></td>
</tr>
<tr >
<th colspan='4'>
<div>
<table> //small table
<tr>
<td></td> <td></td><td></td><td></td><td></td>
</tr>
</table>
</div>
</th>
</tr>
</table>
Each even row of big dynamic table has a table inside that explains data about the row befor(odd row). I want to initially hide hide all even rows (rows which has a table inside).
On click event of each odd row I want to hide/unhide the next even row (which has a table inside)
this is my ajax calls
$.get("invoice_ajax.php",
{"q": test},
function(data)
{
$('#balance').html = data;
with this code I'm trying to slide even rows.
$('#balance').on("click","table",function(event)
{
event.stopPropagation();
var $target = $(event.target);
if ( $target.closest("td").attr("colspan") > 1 )
{
$target.slideUp();
}
else
{
$target.closest("tr").next().find("div").slideToggle();
}
});
At first Ajax call everything works fine and each click shows or hides the next row but on second ajax call on click event of odd row (shows and hides next row) on third call (show, hide, show) after forth call(show, hide, show,hide) and it goes on and on increases with every ajax calls .
Also I don't know how to initially hide even rows.
EDIT: the page in a nutshell - http://pastebin.com/QtTxXnzX