با سلام فرض کنید که یک تگ زیر را داریم
می خواهم با یک تابع ساده جاوا اسکریپت به جای this is test متن مورد نظر خودم چاپ شود مثلا متغیرکد HTML:<p id="ppp"> this is test </p>str="salam"
با سلام فرض کنید که یک تگ زیر را داریم
می خواهم با یک تابع ساده جاوا اسکریپت به جای this is test متن مورد نظر خودم چاپ شود مثلا متغیرکد HTML:<p id="ppp"> this is test </p>str="salam"
کد HTML:<!doctype html> <html> <head> <script language="javascript">
var d=document;
function ge(i){
if(d.all) return d.all(i);
else if(d.getElementById) return d.getElementById(i);
};function setText(id,text){
ge(id).innerHTML=text;
};window.onload=function(){
setText('s','my name is mahdi.');
}
کد HTML:</script> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <p id="s">this is test</p> </body> </html>