var table = document.getElementById("table1"); var tr = table.insertRow(); var td = tr.insertCell(); td.innerHTML= document.getElementById('txt1').value;
I use this code. how to give Id for tr (TableRow). help me.
Just give tr.id = "some_id". This will work.
because you are using standard Javascript, you need to use the setAttribute ("align", "center", 0) function; '.
Try the following:
tr.setAttribute("id", "myIdNameforThisRow", 0);
var table = document.getElementById("table1"); var tr = table.insertRow(); tr.id = 'id_for_this_row'; // Just assign a value to the new row 'id' attribute var td = tr.insertCell(); td.innerHTML= document.getElementById('txt1').value;
create the variable first as var id = 0;
then
tr.id=id; id++;
use this code
Source: https://habr.com/ru/post/895671/More articles:How to update values when repeating dictionary elements? - dictionaryListBox; number of selected items - c #Problem with knowntype attribute in wcf - wcfRes' does not exist in Eclipse - androidResource catalog unavailable - androidIs it safe to use Singleton ExecutorService - javaHow to use NSNotification - iosIs it possible to stop sql query execution? - c #WebTryThreadLock - multithreading'$ null =' in powershell - powershellAll Articles