abstrait: 首先講的是HTML DOM,改變HTML元素內(nèi)容innerHTML,格式:getElementById ("id 名稱").innerHTML ="改變的內(nèi)容";還可以通過class名(ClassName) 標簽名(TagName)去改變,也可以去改變HTML的屬性值,必須是HTML標簽的自帶屬性,格式 :getElem
首先講的是HTML DOM,改變HTML元素內(nèi)容innerHTML,格式:getElementById ("id 名稱").innerHTML ="改變的內(nèi)容";還可以通過class名(ClassName) 標簽名(TagName)去改變,也可以去改變HTML的屬性值,必須是HTML標簽的自帶屬性,格式 :getElementById("").屬性名稱="屬性值";
改變CSS的樣式,格式:getElementById("id名稱").style.屬性名稱 ="屬性值";
時間和日期:獲取當前時間var now =new Date();獲取年月星期幾日時分秒分別是:now.getFullYear; now.getmonth; now.getDay; now.getDate; now.getHours; nowgetMinutes; now.getSeconds;
小案例時間函數(shù):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Time_Function</title>
<link rel="stylesheet" type="text/css" href="../css/css.css">
<link rel="shortcut icon" type="image/x-icon" href="../pictcure/mi.png">
<style type="text/css">
</style>
</head>
<body>
<script type=text/javascript>
var now=new Date;//獲取當前時間
// console.log(now);
//時間函數(shù)
function time (a){
var y=a.getFullYear();
var m=a.getMonth();
var d=a.getDate();
var h=a.getHours();
var m=a.getMinutes();
var s=a.getSeconds();
//顯示年月日時分秒
document.write(y+"-"+m+"-"+d+" "+h+":"+m+":"+s);
//document.write(a.getMonth())
}
var b=time(now);
console.log(b);
</script>
</body>
</html>
老師 有個問題,為什么我單獨去截取出月份就是對的,程式運行出來的月份不對,最后 總會出現(xiàn)一個undefined是什么意思呀?問題找不出來,老師幫幫忙了。
Professeur correcteur:韋小寶Temps de correction:2018-11-26 14:53:56
Résumé du professeur:下次作業(yè)中的代碼記得加上高亮!undefined是未定義的意思?。∧闼搅囊幌挛?!把報錯截圖發(fā)給我