မြေပုံ ဧရိယာ များစုစည်းမှု
ဥပမာ
တိကျသောပုံ-မြေပုံတစ်ခုတွင် <area> ဒြပ်စင်မည်မျှရှိသည်ကို ရှာဖွေပါ-
var x = document.getElementById("planetmap").areas.length;
x ၏ရလဒ်သည် -
3
အောက်တွင် နောက်ထပ် "စမ်းသုံးကြည့်ပါ" ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
ဧရိယာများစုစည်းမှုသည် ပုံ-မြေပုံတစ်ခုရှိ <area> ဒြပ်စင်များအားလုံးကို စုစည်းမှုကို ပြန်ပေးသည်။
မှတ်ချက်- အရင်းအမြစ်ကုဒ်တွင် ပေါ်လာသည်နှင့်အမျှ စုစည်းမှုရှိ အစိတ်အပိုင်းများကို စီထားသည်။
အကြံပြုချက်- href ရည်ညွှန်းချက် သတ်မှတ်ထားသည့် <area> ဒြပ်စင်များ စုစည်းမှုအား ပြန်သွားရန်၊ လင့်ခ် များစုစည်းမှုကို အသုံးပြုပါ။
Browser ပံ့ပိုးမှု
Collection | |||||
---|---|---|---|---|---|
areas | Yes | Yes | Yes | Yes | Yes |
အထားအသို
mapObject.areas
သတ္တိ
Property | Description |
---|---|
length | Returns the number of <area> elements in the collection. Note: This property is read-only |
နည်းလမ်းများ
Method | Description |
---|---|
[index] | Returns the <area> 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 <area> 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 <area> element from the collection with the specified id. Note: Returns null if the id does not exist |
နည်းပညာဆိုင်ရာအသေးစိတ်
DOM ဗားရှင်း- | Core Level 2 Document Object |
---|---|
ပြန်ပို့တန်ဖိုး- | စာရွက်စာတမ်းရှိ ရုပ်ပုံ-မြေပုံရှိ <area> ဒြပ်စင်အားလုံးကို ကိုယ်စားပြုသော HTMLCollection Object တစ်ခု။ အရင်းအမြစ်ကုဒ်တွင် ပေါ်လာသည်နှင့်အမျှ စုစည်းမှုရှိ အစိတ်အပိုင်းများကို စီထားသည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
[ အညွှန်း ]
ပုံ-မြေပုံတွင် ပထမဆုံး <area> ဒြပ်စင်၏ URL ကို ရယူပါ-
var x = document.getElementById("planetmap").areas[0].href;
x ၏ရလဒ်သည် -
https://www.w3schools.com/jsref/sun.htm
ဥပမာ
ပစ္စည်း( အညွှန်း )
ပုံ-မြေပုံတွင် ပထမဆုံး <area> ဒြပ်စင်၏ URL ကို ရယူပါ-
var x = document.getElementById("planetmap").areas.item(0).href;
x ၏ရလဒ်သည် -
https://www.w3schools.com/jsref/sun.htm
ဥပမာ
အမည်ရှိပစ္စည်း( id )
ပုံ-မြေပုံတွင် id="myArea" ဖြင့် <area> ဒြပ်စင်၏ URL ကို ရယူပါ-
var x = document.getElementById("planetmap").areas.namedItem("myArea").href;
x ၏ရလဒ်သည် -
https://www.w3schools.com/jsref/mercur.htm
ဥပမာ
ပုံ-မြေပုံတစ်ခုရှိ <area> element အားလုံးကို လှည့်ပတ်ပြီး ဧရိယာတစ်ခုစီ၏ ပုံသဏ္ဍာန်ကို ထုတ်ပေးသည်-
var x = document.getElementById("planetmap");
var txt = "";
var i;
for (i = 0; i < x.areas.length; i++) {
txt = txt + x.areas[i].shape + "<br>";
}
txt ၏ရလဒ်သည် -
rect
circle
circle
❮ မြေပုံအရာဝတ္ထု