ﮏﯾ ﺯﺍ ﻪﮐ ﺖﺳﺍ ﯽﯾﺎﻫﻩﺮﮔ (ﻪﻋﻮﻤﺠﻣ) ﺖﺴﯿﻟ NodeList
ﯽﺷ
.ﺖﺳﺍ ﺪﻨﻧﺍﺩﺮﮔﯽﻣﺮﺑ HTMLCollection ﯼﺎﺟ ﻪﺑ ﺍﺭ NodeList ﯽﺷ ﮏﯾ (ﺮﺗﯽﻤﯾﺪﻗ) ﺎﻫﺮﮔﺭﻭﺮﻣ ﺯﺍ ﯽ .ﺪﻨﻧﺍﺩﺮﮔﯽﻣﺮﺑ .ﺪﻨﻧﺍﺩﺮﮔﯽﻣﺮﺑ :ﺪﻨﮐ ﯽﻣ ﺏﺎﺨﺘﻧﺍ ﺪﻨﺳ ﮏﯾ ﺭﺩ ﺍﺭ .ﺪﻨﺘﺴﻫ ﯽﺳﺮﺘﺳﺩ ﻞﺑﺎﻗ ﺺﺧﺎﺷ ﻩﺭﺎﻤﺷ ﮏﯾ ﺎﺑ NodeList ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﺻﺎﻨﻋ ﻪﺑ ﯽﺳﺮﺘﺳﺩ ﯼﺍﺮﺑ ﻪﺟﻮﺗ: ﺩﻮﺷ ﯽﻣ ﻉﻭﺮﺷ 0 ﺯﺍ ﺺﺧﺎﺷ. :ﺪﻨﮐ ﯽﻣ ﻒﯾﺮﻌﺗ ﺎﻫ ﻩﺮﮔ ﺖﺴﯿﻟ ﺭﺩ ﺍﺭ ﺎﻫ ﻩﺮﮔ ﺩﺍﺪﻌﺗ .ﺪﯿﻧﺰﺑ ﻪﻘﻠﺣ ﻩﺮﮔ ﮏﯾ ﯼﺎﻫﻩﺮﮔ ﻥﺎﯿﻣ ﺯﺍ ﺪﯿﻫﺍﻮﺧﯽﻣ ﻪﮐ ﺖﺳﺍ ﺪﯿﻔﻣ ﯽﻧﺎﻣﺯ ﺪﯿﻫﺩ ﺮﯿﯿﻐﺗ ﺍﺭ ﻩﺮﮔ ﮏﯾ ﺭﺩ <p> ﺮﺻﺎﻨﻋ ﻡﺎﻤﺗ ﮓﻧﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧHTMLCollection
ءﯽﺷ ﮏﯾ ﻪﺑﺎﺸﻣ ﺎًﺒﯾﺮﻘﺗ childNodes
ﯽﮔﮋﯾﻭ ﯼﺍﺮﺑ ﺍﺭ NodeListquerySelectorAll()
ﺵﻭﺭ ﯼﺍﺮﺑ ﺍﺭ Nod<p>
ﯼﺎﻫ ﻩﺮﮔ ﻡﺎﻤﺗ ﺮﯾﺯ ﺪﮐ ﻝﺎﺜﻣ
const myNodeList = document.querySelectorAll("p");
myNodeList[1]
HTML DOM ﻩﺮﮔ ﺖﺴﯿﻟ ﻝﻮﻃ
length
ﻝﺎﺜﻣ
myNodelist.length
ﻝﺎﺜﻣ
const myNodelist = document.querySelectorAll("p");
for (let i = 0; i < myNodelist.length; i++) {
myNodelist[i].style.color = "red";
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript HTML DOM</h2>
<p>Hello World!</p>
<p>Hello Norway!</p>
<p>Click the button to change the color of all p elements.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
const myNodelist = document.querySelectorAll("p");
for (let i = 0; i < myNodelist.length; i++) {
myNodelist[i].style.color = "red";
}
}
</script>
</body>
</html>
.ﺖﺳﺍ ﻥﺎﺴﮑﯾ ﺎًﺒﯾﺮﻘﺗ HTMLcollection ﮏﯾ ﻭ NodeList ﮏﯾ
ﺪﻧﺍ ﻩﺪﺷ ﺝﺍﺮﺨﺘﺳﺍ a ﺯﺍ ﻪﮐ ﺪﻨﺘﺴﻫ (ﺮﺻﺎﻨﻋ) ﺎﻫ ﻩﺮﮔ (ﺖﺳﺮﻬﻓ) ﺪﻨﻧﺎﻣ ﻪﯾﺍﺭﺁ ﻪﻋﻮﻤﺠﻣ ﻭﺩ ﺮﻫ
.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ (ﻪﻋﻮﻤﺠﻣ) ﺖﺴﯿﻟ ﺭﺩ ﺩﻮﺟﻮﻣ ﺮﺻﺎﻨﻋ ﺩﺍﺪﻌﺗ ﻪﮐ ﺪﻨﺘﺴﻫ length ﯽﮔﮋﯾﻭ ﯼﺍﺭﺍﺩ
HTMLCollection ﺯﺍ ﯼﺍ ﻪﻋﻮﻤﺠﻣ ﺪﻨﺳ ﺮﺻﺎﻨﻋ ﺖﺳﺍ.
NodeList ﻪﻋﻮﻤﺠﻣﺯﺍ ﯼﺍ ﻩﺮﮔﺪﻨﺳ ﯼﺎﻫ (ﻩﺮﮔﻩﺮﮔ ،ﺮﺼﻨﻋ ﯼﺎﻫﻩﺮﮔ ﻭ ﯽﮔﮋ
.ﺩﺍﺩ ﺭﺍﺮﻗ ﺱﺮﺘﺳﺩ ﺭﺩ ﺎﻬﻧﺁ ﺖﺳﺮﻬﻓ ﻩﺭﺎﻤﺷ ﺎﯾ ﻪﺳﺎﻨﺷ ،ﻡﺎﻧ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ HTMLCollection ﯼﺎﻫ ﻢﺘ
.ﺖﺳﺍ ﯽﺳﺮﺘﺳﺩ ﻞﺑﺎﻗ ﺎﻬﻧﺁ ﺖﺳﺮﻬﻓ ﻩﺭﺎﻤﺷ ﺎﺑ ﻂﻘﻓ NodeList ﺩﺭﺍﻮﻣ
.ﺩﺮﮐ ﺪﻫﺍﻮﺧ ﺮﯿﯿﻐﺗ ﺰﯿﻧ HTMLCollection ﺭﺩ ﺩﻮﺟﻮﻣ ﺖﺴﯿﻟ ،ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ DOM ﺭﺩ ﯽﺘﺴﯿﻟ ﻪﺑ ﺍﺭ
NodeList ﻪﻋﻮﻤﺠﻣ ﮏﯾ ﺐﻠﻏﺍ ﺎﺘﺴﯾﺍ ﺮﺼﻨﻋ ﮏﯾ ﺮﮔﺍ :ﻝﺎﺜﻣ .ﺖﺳﺍ
.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﺖﺑﺎﺛ NodeList ﮏﯾ .ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ ﻩﺪﻧﺯ NodeList ﮏﯾ .ﺖﺴﯿﻧ ﺭﻮﻄﻨﯾﺍ ﺎﻣﺍ ،ﺪﺳﺮﺑ ﺮﻈﻧ ﻪﺑ ﻪﯾﺍﺭﺁ ﮏﯾ ﻪﯿﺒﺷ ﺖﺳﺍ ﻦﮑﻤﻣ NodeList ﮏﯾ .ﺪﯿﻨﮐ ﻪﻌﺟﺍﺮﻣ ﺺﺧﺎﺷ ﺱﺎﺳﺍ ﺮﺑ ﻥﺁ ﯼﺎﻫ ﻩﺮﮔ ﻪﺑ ﻭ ﺪﯿﻧﺰﺑ ﻪﻘﻠﺣ NodeList ﻖﯾﺮﻃ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ .ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ NodeList ﺭﺩ()join ﺎﯾ()push()، pop ﺪﻨﻧﺎﻣ ﻪﯾﺍﺭﺁ ﯼﺎﻫ ﺵﻭﺭ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻤﻧ ﺎgetElementsByClassName()
ﻭ querySelectorAll()
childNodes
ﯽﮔﮋﯾ !ﺖﺴﯿﻧ ﻪﯾﺍﺭﺁ