点击图片箭头回到顶部案例

本文介绍了一个使用jQuery实现的网页案例,通过动态修改页面中多个相同元素的内容来演示jQuery的选择器和事件处理功能。案例中,点击特定按钮可以使页面滚动到顶部,并且当点击每个标题元素时,其文本内容会自动增加一个破折号和数字。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>02-jQuery-动态创建表格案例</title>
 6     <script src="jquery-1.11.3.js"></script>
 7     <style>
 8             .top{
 9                 position: fixed;
10                 bottom: 40px;
11                 right: 10px;
12                 cursor:pointer;
13 
14             }
15     </style>
16     <script>
17             $(function(){
18                $('.top').on('click',function(){
19                    $(window).scrollTop(0);
20                    $(window).scrollLeft(0);
21                });
22                $('#J_Box').on('click','h1',function(){
23                    this.innerHTML+='-';
24                    $(this).text($(this).text()+1);
25                })
26             })
27     </script>
28 <body>
29 <div class="top" id="top">
30     <img src="imgs/bk-top3.jpg" alt="">
31 </div>
32 <div id="J_Box">
33     <h1>爱情保卫战</h1>
34     <h1>爱情保卫战</h1>
35     <h1>爱情保卫战</h1>
36     <h1>爱情保卫战</h1>
37     <h1>爱情保卫战</h1>
38     <h1>爱情保卫战</h1>
39     <h1>爱情保卫战</h1>
40     <h1>爱情保卫战</h1>
41     <h1>爱情保卫战</h1>
42     <h1>爱情保卫战</h1>
43     <h1>爱情保卫战</h1>
44     <h1>爱情保卫战</h1>
45     <h1>爱情保卫战</h1>
46     <h1>爱情保卫战</h1>
47     <h1>爱情保卫战</h1>
48     <h1>爱情保卫战</h1>
49     <h1>爱情保卫战</h1>
50     <h1>爱情保卫战</h1>
51     <h1>爱情保卫战</h1>
52     <h1>爱情保卫战</h1>
53     <h1>爱情保卫战</h1>
54     <h1>爱情保卫战</h1>
55     <h1>爱情保卫战</h1>
56     <h1>爱情保卫战</h1>
57     <h1>爱情保卫战</h1>
58     <h1>爱情保卫战</h1>
59     <h1>爱情保卫战</h1>
60     <h1>爱情保卫战</h1>
61     <h1>爱情保卫战</h1>
62     <h1>爱情保卫战</h1>
63     <h1>爱情保卫战</h1>
64     <h1>爱情保卫战</h1>
65     <h1>爱情保卫战</h1>
66     <h1>爱情保卫战</h1>
67     <h1>爱情保卫战</h1>
68     <h1>爱情保卫战</h1>
69     <h1>爱情保卫战</h1>
70     <h1>爱情保卫战</h1>
71     <h1>爱情保卫战</h1>
72     <h1>爱情保卫战</h1>
73     <h1>爱情保卫战</h1>
74     <h1>爱情保卫战</h1>
75     <h1>爱情保卫战</h1>
76     <h1>爱情保卫战</h1>
77     <h1>爱情保卫战</h1>
78     <h1>爱情保卫战</h1>
79     <h1>爱情保卫战</h1>
80 </div>
81 </body>
82 </html>

 

转载于:https://www.cnblogs.com/yangguoe/p/8175994.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值