19
rated 0 times
[
21]
[
2]
/ answers: 1 / hits: 17368
/ 11 Years ago, mon, february 18, 2013, 12:00:00
My task is to make a page with a table and a button. When the user presses a button, one row is added to the table.
So, I have a button on my html page ( <button id=my_button>Bla-bla</button>
),
and a table ( <table id=my_table>
). And I have a separate file for JavaScript. In that file I wrote:
$(function() {
$(my_button).click(function(){
tbl = document.getElementById(my_table);
row = tbl.insertRow(0);
var newCell = row.insertCell(0);
newCell.height=300;
newCell.innerHTML=Some New Text;
});
});
But there is a problem: when I press the button, the row is added for several milliseconds, then it vanishes and I see the table without the new row again.
What is the problem and how can I solve it?
More From » jquery