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