Table insertRow() နည်းလမ်း
ဥပမာ
ဇယားတစ်ခု၏ ပထမဆုံး အနေအထားတွင် အတန်းအသစ်(များ)ကို ထည့်ပါ (၎င်းတွင် အကြောင်းအရာအချို့ပါသော <td> ဒြပ်စင်တစ်ခုကို ထည့်သွင်းပါ)။
// Find a <table> element with id="myTable":
var table = document.getElementById("myTable");
// Create an empty <tr> element and add it to the 1st position of the table:
var row = table.insertRow(0);
// Insert new cells (<td> elements) at the 1st and 2nd position of the "new" <tr> element:
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
// Add some text to the new cells:
cell1.innerHTML = "NEW CELL1";
cell2.innerHTML = "NEW CELL2";
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
insertRow() နည်းလမ်းသည် ဗလာ <tr> ဒြပ်စင်တစ်ခုကို ဖန်တီးပြီး ဇယားတစ်ခုသို့ ပေါင်းထည့်သည်။
insertRow() နည်းလမ်းသည် ဇယားရှိ သတ်မှတ်ထားသော အညွှန်းတွင် အတန်းအသစ်(များ)ကို ထည့်သွင်းသည်။
မှတ်ချက်- <tr> ဒြပ်စင်တစ်ခု သို့မဟုတ် တစ်ခုထက်ပိုသော <th> သို့မဟုတ် <td> ဒြပ်စင်များ ပါဝင်ရပါမည်။
အကြံပြုချက်- အတန်းတစ်ခုကို ဖယ်ရှားရန် deleteRow() နည်းလမ်းကို အသုံးပြု ပါ။
Browser ပံ့ပိုးမှု
Method | |||||
---|---|---|---|---|---|
insertRow() | Yes | Yes | Yes | Yes | Yes |
အထားအသို
tableObject.insertRow(index)
ကန့်သတ်တန်ဖိုးများ
Value | Description |
---|---|
index | Required in Firefox and Opera, optional in IE, Chrome and Safari. A number that specifies the position of the row to insert (starts at 0). The value of 0 results in that the new row will be inserted at the first position. The value of -1 can also be used, this results in a new row being inserted at the last position. This parameter is required in Firefox and Opera, but optional in Internet Explorer, Chrome and Safari.If this parameter is omitted, insertRow() inserts a new row at the last position in Chrome, IE, Firefox and Opera, and at the first position in Safari. |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ထည့်သွင်းထားသော <tr> ဒြပ်စင် |
---|
နောက်ထပ် ဥပမာများ
ဥပမာ
အတန်း(များ)ကို ဖန်တီးပြီး ဖျက်ပါ-
function myCreateFunction() {
var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = "NEW CELL1";
cell2.innerHTML = "NEW CELL2";
}
function myDeleteFunction() {
document.getElementById("myTable").deleteRow(0);
}
ဆက်စပ်စာမျက်နှာများ
HTML ရည်ညွှန်း- HTML <tr> တဂ်
❮ ဇယားအရာဝတ္ထု