HTML单页模板

HTML单页模板,第1张

你这样说 ,我看这样看, 还真不能知道你想要什么样的效果!

假如100页 怎么显示

1:要是你有多少页显示多少页,最简单了 , 你js for 循环 生成 div 即可

如 <div style="..."><a href="#" >页数 </a></div> 或者 给div或 a 加 点击事件 来实现提交

2:要是 显示例如 1 2 3 ....50,51,52 ... 100 , 你要写点逻辑了

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<script type="text/javascript">

// 随机选取函数 参数为选取的数量

function randomStr(num) {

// 保存随机句子

var strs = [

'1',

'2',

'3',

'4',

'5',

'6',

'7',

'8',

'9'

],

text = ''

// 需要选取的数量

num = num >strs.length

? strs.length

: num

console.log(num)

while (num--) {

i = Math.floor(Math.random() * strs.length)

console.log(i)

text += '<p>' + strs[i] + '</p>'

// 删除选中的数组下标,避免重复

strs.splice(i, 1)

}

// 示例

document.getElementById('demo').innerHTML = text

}

window.onload = function () {

randomStr(3)

}

</script>

</head>

<body>

<div id="demo"></div>

</body>

</html>


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存