html如何设置定时更换文本的功能?

html如何设置定时更换文本的功能?,第1张

以前弄过类似的,你可以看看修改下。

这个是只有4条,定时切换。想改成0点 修改时间or获取时间就行。已测试可运行。

<!DOCTYPE html>

<HTML>

<HEAD>

    <meta charset="UTF-8">

    <TITLE>change by su </TITLE>

    <style type="text/css">

        #contain{

            overflow:hiddenlist-style:nonewidth:350pxheight:55pxmargin:0pxpadding:0

        }

        #contain p{

            height:30pxline-height:30pxwhite-space:nowrapoverflow:hiddenfont-size:15px

        }

    </style>

</HEAD>

<BODY>

<div id="contain">

    <p>这是第一条文本</p>

    <p>我是第二条文本!</p>

    <p>没错的话,我是第三条文本</p>

    <p>我去,我竟然是最后一条文本</p>

</div>

<script>

    function setTime(){

        var contain=document.getElementById("contain")

        contain.appendChild(contain.firstChild)

    }

    setInterval("setTime()",2000)

</script>

</BODY>

</HTML>

    <script language="JavaScript">   

      function myrefresh(){   

        window.location.reload()   

      }   

      setTimeout('myrefresh()',1000) //指定1秒刷新一次   

    </script>

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

</head>

<body>

<h1 id="time"></h1>

<script>

//Start DynamicTime

function DynamicTime () {

var now = new Date()

var Hs = now.getHours()/*获取本地小时*/

var Ms = now.getMinutes()/*获取本地分钟*/

var Ss = now.getSeconds()/*获取本地秒数*/

/*当< 时、分、秒 >小于10时,前面添加 “0”*/

var H = ((Hs < 10) ? "0" : "") + Hs

var M = ((Ms < 10) ? "0" : "") + Ms

var S = ((Ss < 10) ? "0" : "") + Ss

var time = H+":"+M+":"+S

//显示变化的时间,添加标签ID

var Time = document.getElementById("time")

Time.innerHTML = getYearMonthTodaysDate() + "   " + time

}

var PerSecondDynamic = setInterval("DynamicTime()",1)

//End DynamicTime

function getYearMonthTodaysDate() {

var now = new Date()

var days = new Array('星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六')

var months = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12')

/*获取本月时间,如果本月时间小于10则在前面添加“0”*/

var month = ((now.getMonth() < 10) ? "0" : "") + now.getMonth()

/*获取当天时间,如果当天时间小于10则在前面添加“0”*/

var date = ((now.getDate() < 10) ? "0" : "") + now.getDate()

var today = now.getFullYear()+"年"+month+"月"+date+"日   "+days[now.getDay()]

return (today)

}

</script>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7362832.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存