<script type="text/javascript">
function bijiao(x,y){
if(x>y){
document.write(x + "比較大");
}
else if(x<y){
document.write(y + "比較大");
}
else{
document.write("他倆一樣大");
}
}
bijiao(5,5);
</script>
function bijiao(x,y){
if(x>y){
document.write(x + "比較大");
}
else if(x<y){
document.write(y + "比較大");
}
else{
document.write("他倆一樣大");
}
}
bijiao(5,5);
</script>
2021-07-09
<script type="text/javascript">
function replaceMessage(){
var newnode=document.createElement("i");
var old=document.getElementById("oldnode");
newnode.innerText = old.innerText;
oldnode.parentNode.replaceChild (newnode,old) ;
}
</script>
function replaceMessage(){
var newnode=document.createElement("i");
var old=document.getElementById("oldnode");
newnode.innerText = old.innerText;
oldnode.parentNode.replaceChild (newnode,old) ;
}
</script>
2021-07-01
<body>
<span id="text"></span>
</body>
<script>
document.getElementById("text").innerHTML="系好安全帶,準(zhǔn)備啟航(1)";
document.write("<br/>系好安全帶,準(zhǔn)備啟航(2)");
alert("準(zhǔn)備好了,啟航吧")
</script>
</html>
<span id="text"></span>
</body>
<script>
document.getElementById("text").innerHTML="系好安全帶,準(zhǔn)備啟航(1)";
document.write("<br/>系好安全帶,準(zhǔn)備啟航(2)");
alert("準(zhǔn)備好了,啟航吧")
</script>
</html>
2021-06-24
調(diào)用函數(shù)時要添加(),不過用chrom瀏覽器測試時,剛打開頁面會有提示,關(guān)閉時沒有。
2021-06-12
document.write(mydate.getFullYear()+"年"+mydate.getMonth()+"月"+mydate.getDay()+"日"+" "+myarray[mydate.getDay()]+"--班級總分為:");
var arry1= scoreStr.split(";");
var num =0;
for(var i=0;i<arry1.length;i++){
num+=Number(arry1[i].split(":")[1]);
}
document.write(Math.round(num/10));
var arry1= scoreStr.split(";");
var num =0;
for(var i=0;i<arry1.length;i++){
num+=Number(arry1[i].split(":")[1]);
}
document.write(Math.round(num/10));
2021-05-08
//第一次篩選,找出都是大一的信息
var newArr = [];
for(var i = 0;i<infos.length;i++){
if(infos[i][3] == "大一"){
newArr.push(infos[i]);
}
}
//第二次篩選,找出都是女生的信息
for(var j = 0;j<=newArr.length;j++){
if(newArr[j][1] == "女"){
document.write(newArr[j][0]+"<br>")
}
}
var newArr = [];
for(var i = 0;i<infos.length;i++){
if(infos[i][3] == "大一"){
newArr.push(infos[i]);
}
}
//第二次篩選,找出都是女生的信息
for(var j = 0;j<=newArr.length;j++){
if(newArr[j][1] == "女"){
document.write(newArr[j][0]+"<br>")
}
}
2021-03-22
<script type="text/javascript">
//創(chuàng)建數(shù)組
var arr=new Array();
var arr=['*','##','***','&&','****','##*'];
//顯示數(shù)組長度
alert("數(shù)組的長度為"+(arr.length));
//將數(shù)組內(nèi)容輸出,完成達(dá)到的效果。
document.write("<br>"+arr[0]+"<br>"+arr[2]+"<br>"+arr[4]);
</script>
//創(chuàng)建數(shù)組
var arr=new Array();
var arr=['*','##','***','&&','****','##*'];
//顯示數(shù)組長度
alert("數(shù)組的長度為"+(arr.length));
//將數(shù)組內(nèi)容輸出,完成達(dá)到的效果。
document.write("<br>"+arr[0]+"<br>"+arr[2]+"<br>"+arr[4]);
</script>
2021-03-22
function app1(a,b){
var a,b,c;
if(a > b)
{c = a;
}
else if(a = b)
{c = "兩數(shù)相等。";}
else
{c = b;}
return c;
}
var a,b,c;
if(a > b)
{c = a;
}
else if(a = b)
{c = "兩數(shù)相等。";}
else
{c = b;}
return c;
}
2021-03-21