TableRow ဆဲလ် များစုစည်းမှု
ဥပမာ
ပထမတန်းရှိ ဆဲလ်အရေအတွက်ကို ပြပါ-
var x = document.getElementById("myTable").rows[0].cells.length;
x ၏ရလဒ်သည် -
2
အောက်တွင် နောက်ထပ် "စမ်းသုံးကြည့်ပါ" ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ဆဲလ်များစုစည်းမှုသည် ဇယားအတန်းရှိ <td> သို့မဟုတ် <th> ဒြပ်စင်အားလုံး၏ အစုအဝေးကို ပြန်ပေးသည်။
မှတ်ချက်- အရင်းအမြစ်ကုဒ်တွင် ပေါ်လာသည်နှင့်အမျှ စုစည်းမှုရှိ အစိတ်အပိုင်းများကို စီထားသည်။
Browser ပံ့ပိုးမှု
Collection | |||||
---|---|---|---|---|---|
cells | Yes | Yes | Yes | Yes | Yes |
အထားအသို
tableObject.cells
သတ္တိ
Property | Description |
---|---|
length | Returns the number of <td> and/or <th> elements in the collection. Note: This property is read-only |
နည်းလမ်းများ
Method | Description |
---|---|
[index] | Returns the <td> and/or <th> element from the collection with the specified index (starts at 0). Note: Returns null if the index number is out of range |
item(index) | Returns the <td> and/or <th> element from the collection with the specified index (starts at 0). Note: Returns null if the index number is out of range |
namedItem(id) | Returns the <td> and/or <th> element from the collection with the specified id. Note: Returns null if the id does not exist |
နည်းပညာဆိုင်ရာအသေးစိတ်
DOM ဗားရှင်း- | Core Level 2 Document Object |
---|---|
ပြန်ပို့တန်ဖိုး- | <tr> ဒြပ်စင်ရှိ <td> နှင့်/သို့မဟုတ် <th> ဒြပ်စင်အားလုံးကို ကိုယ်စားပြုသော HTMLCollection Object တစ်ခု။ အရင်းအမြစ်ကုဒ်တွင် ပေါ်လာသည်နှင့်အမျှ စုစည်းမှုရှိ အစိတ်အပိုင်းများကို စီထားသည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
[ အညွှန်း ]
ဇယား၏ပထမအတန်းရှိ ပထမဆဲလ်၏အတွင်း HTML ကို သတိပေးပါ-
alert(document.getElementById("myTable").rows[0].cells[0].innerHTML);
ဥပမာ
ပစ္စည်း( အညွှန်း )
ဇယား၏ပထမအတန်းရှိ ပထမဆဲလ်၏အတွင်း HTML ကို သတိပေးပါ-
alert(document.getElementById("myTable").rows[0].cells.item(0).innerHTML);
ဥပမာ
အမည်ရှိပစ္စည်း( id )
ဇယား၏ပထမတန်းရှိ id="myTd" ဖြင့် ဆဲလ်၏အတွင်း HTML ကို သတိပေးပါ-
alert(document.getElementById("myTable").rows[0].cells.namedItem("myTd").innerHTML);
ဥပမာ
ပထမဇယားဆဲလ်၏ အကြောင်းအရာကို ပြောင်းပါ-
var x = document.getElementById("myTable").rows[0].cells;
x[0].innerHTML = "NEW CONTENT";
❮ TableRow အရာဝတ္ထု