.ﺪﻫﺩ ﻡﺎﺠﻧﺍ ﺪﻧﺍﻮﺗ ﯽﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﻪﮐ ﺖﺳﺍ ﯽﯾﺎﻫﺭﺎﮐ ﺯﺍ ﻪﻧﻮﻤﻧ ﺪﻨﭼ ﻞﻣﺎﺷ ﻪﺤﻔﺻ ﻦﯾﺍ
.ﺖﺳﺍ getElementById()
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ HTML ﯼﺎﻫ ﺵﻭﺭ ﺯﺍ ﯼﺭﺎﯿﺴﺑ ﺯﺍ ﯽﮑﯾ
،("ﻮﻣﺩ"=id ﺎﺑ) HTML ﺮﺼﻨﻋ ﮏﯾ "ﺖﻓﺎﯾ" ﺮﯾﺯ ﻝﺎﺜﻣ
document.getElementById("demo").innerHTML = "Hello JavaScript";
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>
</body>
</html>
:ﺩﺮﯾﺬﭘ ﯽﻣ ﺍﺭ ﯽﮑﺗ ﻢﻫ ﻭ ﯽﯾﺎﺗﻭﺩ ﯼﺎﻫ ﻝﻮﻗ ﻞﻘﻧ ﻢﻫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
document.getElementById('demo').innerHTML = 'Hello JavaScript';
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">Click Me!</button>
</body>
</html>
:ﺪﻫﺩﯽﻣ ﺮﯿﯿﻐﺗ ﺍﺭ <img>
ﮓﺗ ﮏﯾ code class="w3-codespan">src (source)> ﯽﮔﮋﯾﻭ
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p>JavaScript can change HTML attribute values.</p>
<p>In this case JavaScript changes the value of the src (source) attribute of an image.</p>
<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>
<img id="myImage" src="pic_bulboff.gif" style="width:100px">
<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>
</body>
</html>
ﺖﺳﺍ HTML ﮏﯾ ﺮﯿﯿﻐﺗ ﯽﻋﻮﻧ ،HTML ﺮﺼﻨﻋ ﮏﯾ ﮏﺒﺳ ﺮﯿﯿﻐﺗ
document.getElementById("demo").style.fontSize = "35px";
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change the style of an HTML element.</p>
<button type="button" onclick="document.getElementById('demo').style.fontSize='35px'">Click Me!</button>
</body>
</html>
:ﺩﺍﺩ ﻡﺎﺠﻧﺍ ﺶﯾﺎﻤﻧ<"code class="w3-codespan> ﮏﺒﺳ ﺮﯿﯿﻐﺗ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ HTML ﺮﺻﺎﻨﻋ ﻥﺩﺮﮐ ﻥﺎﻬﻨﭘ
document.getElementById("demo").style.display = "none";
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can hide HTML elements.</p>
<button type="button" onclick="document.getElementById('demo').style.display='none'">Click Me!</button>
</body>
</html>
:ﺩﻮﺷ ﻡﺎﺠﻧﺍ ﺶﯾﺎﻤﻧ<"code class="w3-codespan> ﮏﺒﺳ ﺮﯿﯿﻐﺗ ﺎﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﻦﯿﻨﭽﻤﻫ HTML ﻥﺎﻬﻨﭘ ﺮﺻﺎﻨﻋ ﺶﯾﺎﻤﻧ
document.getElementById("demo").style.display = "block";
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p>JavaScript can show hidden HTML elements.</p>
<p id="demo" style="display:none">Hello JavaScript!</p>
<button type="button" onclick="document.getElementById('demo').style.display='block'">Click Me!</button>
</body>
</html>
ﺪﻨﺘﺴﻫ ﯽﺗﻭﺎﻔﺘﻣ ﻼًﻣﺎﮐ ﯼﺎﻫﻥﺎﺑﺯ ﻭﺩ ﺮﻫ ﺍﻭﺎﺟ ﻭ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
.ﺪﺷ ﻞﯾﺪﺒﺗ ECMA ﺩﺭﺍﺪﻧﺎﺘﺳﺍ ﮏﯾ ﻪﺑ ﻭ ﺪﺷ ﻉﺍﺮﺘﺧﺍ 1995 ﻝﺎﺳ ﺭﺩ ﭻﯾﺍ ﻥﺍﺪﻧﺮﺑ ﻂﺳﻮﺗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ
ECMA-262 ﺖﺳﺍ ﺩﺭﺍﺪﻧﺎﺘﺳﺍ ﯽﻤﺳﺭ ﻡﺎﻧ. ECMAScript ﺖﺳﺍ ﻥﺎﺑﺯ ﻦﯾﺍ ﯽﻤﺳﺭ ﻡﺎﻧ.