lastChild property
lastChild property သည် element ၏ နောက်ဆုံး
node ကို သိမ်းဆည်းထားသည်။ အကယ်၍ element တွင် child
elements များ မရှိပါက null ကို ပြန်ပေးသည်။
Syntax
element.lastChild;
ဥပမာ
Element ၏ နောက်ဆုံး node ၏ text ကို ရယူကြည့်ရအောင်။
<div id="parent">text<p>parag</p><!--com--></div>
let parent = document.querySelector('#parent');
let text = parent.lastChild.textContent;
console.log(text);
Code run ပြီးနောက်ရရှိသော ရလဒ်။
'com'
ဆက်လက်ဖတ်ရှုရန်
-
lastElementChildproperty,
သည် နောက်ဆုံး element ကို ထည့်သွင်းထားသည် -
firstChildproperty,
သည် ပထမဆုံး node ကို ထည့်သွင်းထားသည် -
childNodesproperty,
သည် element ၏ node အားလုံးကို ထည့်သွင်းထားသည်