javascript怎么实现按钮点击进行跳转


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

<!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>

</head>

 

<body>

    <button>点点点</button>

    <div></div>

    <script>

        var btn = document.querySelector('button')

        var div = document.querySelector('div')

        btn.addEventListener('click', function () {

            // location.href = 'http://www.baidu.com';

            var timer = 5;

            setInterval(function () {

                if (timer == 0) {

                    location.href = 'http://www.php.cn';

                } else {

                    div.innerHTML = '你还有' + timer + '秒就可以跳转了';

                    timer--

                }

            },1000)

            /*  setInterval(function(){

                 div.innerHTML = '你还有' + timer + '秒就可以跳转了'

                 timer--;

             },1000) */

        });

    </script>

</body>

 

</html>

【推荐学习:javascript高级教程

以上就是javascript怎么实现按钮点击进行跳转的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

360怎么开启javascript

js遇到代码出现问题时调试代码的方法

javascript混淆与解混淆的详细介绍(附代码)

layui怎么固定表格的表头

javascript核心对象有哪些

javascript中date对象的方法有哪些

js中==和===的区别是什么

javascript实现单张或多张图片持续无缝滚动

javascript怎么隐藏herf

javascript数组如何求和

更多相关阅读请进入《javascript》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...