zhaoxing
2023-11-03 4e7efbab6725c98264be94a5aeaf14f1e41ee6e5
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图列</title>
    <script src="../../lib/jquery/jquery-1.11.3.min.js"></script>
    <style>
        ul {
            list-style: none;
        }
 
        ul {
            display: flex;
            flex-direction: row;
            padding: 0;
            margin: 0;
 
        }
 
        ul li {
            width: 70px;
            height: 20px;
            color: aliceblue;
            background: rgba(32, 160, 255, 0.3);
            text-align: center;
            line-height: 20px;
            font-family: Arial, Helvetica, sans-serif;
            box-sizing: border-box;
            /* box-shadow: 3px 3px 3px #eee;; */
            border-right: 1px solid #f5f5f5;
            cursor: pointer
        }
 
        #day04 {
            width: 130px;
        }
 
        .showTime {
            width: 890px;
            height: 200px;
            /* border: 1px solid #ffff66; */
        }
 
        .showTime p {
            width: 100%;
            height: 100%;
            margin: 0;
        }
 
        .navbar {
            display: flex;
            flex-direction: column;
            /* align-items: center; */
            /* justify-content: center; */
        }
 
        .touchOn {
            background: #ff9966;
            /* font-size: 20px; */
            font-weight: bold;
        }
    </style>
</head>
 
<body>
 
    <div class="navbar">
        <ul>
            <li id="day01">国控点</li>
            <li id="day02">微站</li>
            <li id="day03">监测点</li>
            <li id="day04">车辆 | 道路 | 区域</li>
 
        </ul>
        <div class="showTime">
            <p id="content01">
                <img src="../../img/tuglie/gk_pm25.png" alt="">
                <img src="../../img/tuglie/gk_pm10.png" alt="">
                <img src="../../img/tuglie/gk_no2.png" alt="">
                <img src="../../img/tuglie/gk_co.png" alt="">
                <img src="../../img/tuglie/gk_so2.png" alt="">
                <img src="../../img/tuglie/gk_o3.png" alt="">
            </p>
            <p id="content02">
                <img src="../../img/tuglie/wz_pm25.png" alt="">
                <img src="../../img/tuglie/wz_pm10.png" alt="">
                <img src="../../img/tuglie/wz_no2.png" alt="">
                <img src="../../img/tuglie/wz_co.png" alt="">
                <img src="../../img/tuglie/wz_so2.png" alt="">
                <img src="../../img/tuglie/wz_o3.png" alt="">
            </p>
            <p id="content03">
                <img src="../../img/tuglie/jc_tsp.png" alt="">
            </p>
            <p id="content04">
                <img src="../../img/tuglie/other_pm2.5.png" alt="">
                <img src="../../img/tuglie/other_pm10.png" alt="">
                <img src="../../img/tuglie/other_no2.png" alt="">
                <img src="../../img/tuglie/other_no.png" alt="">
                <img src="../../img/tuglie/other_co.png" alt="">
                <img src="../../img/tuglie/other_nox.png" alt="">
            </p>
        </div>
    </div>
 
 
</body>
<script>
    var thisWidget;
    function initWidgetView(_thisWidget) {
        thisWidget = _thisWidget
    }
 
    $(function () {
        $(".showTime").find("p").hide();//先隐藏所有p元素
        $("#day04").click();
    })
    $("ul li").click(function () {
        if (!$(this).hasClass("touchOn")) {//$(this)表示所点击的元素,在这里极为好用
            $(this).addClass("touchOn");//给所点击元素加上touchOn类
        }
        $(this).siblings().removeClass("touchOn");//移除其他元素的touchOn类
        var id = $(this).attr('id');//获取所点击元素的id
        id = id.slice(4, 5);//获取所点击元素的id的序号,方便与下文p的id对应         
        var showId = $(".showTime").find("p").eq((id - 1)).attr('id');//因为index从0开始,这里须id-1
        showId = '#' + showId;
        $(showId).show();
        $(showId).siblings().hide();//注意!!!这里不能写$("showId")
    })
</script>
 
</html>