TableRow insertCell() နည်းလမ်း
ဥပမာ
id="myRow" ဖြင့် ဇယားအတန်းတစ်ခု၏အစတွင် အကြောင်းအရာဖြင့် ဆဲလ်အသစ်(များ)ကို ထည့်သွင်းပါ-
var row = document.getElementById("myRow");
var x = row.insertCell(0);
x.innerHTML = "New cell";
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
insertCell() နည်းလမ်းသည် လက်ရှိအတန်းထဲသို့ ဆဲလ်တစ်ခုကို ထည့်သွင်းသည်။
အကြံပြုချက်- လက်ရှိဇယားအတန်းရှိ ဆဲလ်တစ်ခုကိုဖျက်ရန် deleteCell() နည်းလမ်းကို အသုံးပြု ပါ။
Browser ပံ့ပိုးမှု
Method | |||||
---|---|---|---|---|---|
insertCell() | Yes | Yes | Yes | Yes | Yes |
အထားအသို
tablerowObject.insertCell(index)
ကန့်သတ်တန်ဖိုးများ
Value | Description |
---|---|
index | Required in Firefox and Opera, optional in IE, Chrome and Safari. A number (starts at 0) that specifies the position of the new cell in the current row. The value of 0 results in that the new cell will be inserted at the first position. The value of -1 can also be used; which results in that the new cell will be inserted at the last position. If this parameter is omitted, insertCell() inserts the new cell at the last position in IE and at the first position in Chrome and Safari. This parameter is required in Firefox and Opera, but optional in Internet Explorer, Chrome and Safari. |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ထည့်သွင်းထားသော ဆဲလ်ဒြပ်စင် |
---|
နောက်ထပ် ဥပမာများ
ဥပမာ
id="myRow" ပါသော ဇယားတစ်ခု၏အဆုံးတွင် အကြောင်းအရာဖြင့် ဆဲလ်အသစ်(များ)ကို ထည့်သွင်းပါ-
var row = document.getElementById("myRow");
var x = row.insertCell(-1);
x.innerHTML = "New cell";
ဥပမာ
id="myRow" ဖြင့် ဇယားအတန်းတစ်ခု၏ အညွှန်းအနေအထား 2 တွင် အကြောင်းအရာဖြင့် ဆဲလ်အသစ်(များ)ကို ထည့်သွင်းပါ-
var row = document.getElementById("myRow");
var x = row.insertCell(2);
x.innerHTML = "New cell";
ဥပမာ
ပထမဇယားအတန်း၏အစတွင် ဆဲလ်အသစ်(များ)ကို ထည့်ပါ။ ဇယားအတန်းများ စုစည်းမှု (.rows[0]) သည် id "myTable" ဖြင့် ဇယားရှိ <tr> ဒြပ်စင်အားလုံး၏ အစုအဝေးကို ပြန်ပေးသည်။ နံပါတ် [0] သည် ဤဥပမာတွင်၊ ပထမဇယားအတန်းကို ပြန်လည်ရယူရန် အစိတ်အပိုင်းကို သတ်မှတ်သည်။ ထို့နောက် အညွှန်းနေရာ -1 တွင် ဆဲလ်အသစ်များထည့်သွင်းရန် insertcell() ကိုအသုံးပြုသည်။
var firstRow = document.getElementById("myTable").rows[0];
var x = firstRow.insertCell(-1);
x.innerHTML = "New cell";
ဥပမာ
id="myRow" ပါသော ဇယားအတန်းမှ ပထမဆဲလ်(များ)ကို ဖျက်ပါ-
var row = document.getElementById("myRow");
row.deleteCell(0);
ဥပမာ
ဇယားတစ်ခု၏အစတွင် အတန်းအသစ်(များ)ကိုထည့်ပါ။ insertRow() method သည် id="myTable" ပါသော ဇယားတစ်ခု၏ ပထမနေရာ (အစ) ကို ဇယားတစ်ခုရှိ သတ်မှတ်ထားသော အညွှန်းတွင် အတန်းအသစ်တစ်ခု ထည့်သွင်းသည်။ ထို့နောက် အတန်းအသစ်တွင် ဆဲလ်များထည့်ရန် insertCell() နည်းလမ်းကို အသုံးပြုသည်။
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";
❮ TableRow အရာဝတ္ထု