<legend id='g1jIK'><style id='g1jIK'><dir id='g1jIK'><q id='g1jIK'></q></dir></style></legend>

      <small id='g1jIK'></small><noframes id='g1jIK'>

    1. <i id='g1jIK'><tr id='g1jIK'><dt id='g1jIK'><q id='g1jIK'><span id='g1jIK'><b id='g1jIK'><form id='g1jIK'><ins id='g1jIK'></ins><ul id='g1jIK'></ul><sub id='g1jIK'></sub></form><legend id='g1jIK'></legend><bdo id='g1jIK'><pre id='g1jIK'><center id='g1jIK'></center></pre></bdo></b><th id='g1jIK'></th></span></q></dt></tr></i><div id='g1jIK'><tfoot id='g1jIK'></tfoot><dl id='g1jIK'><fieldset id='g1jIK'></fieldset></dl></div>
    2. <tfoot id='g1jIK'></tfoot>

          <bdo id='g1jIK'></bdo><ul id='g1jIK'></ul>

      1. JS原生非dialog信息提示框的示例代码

        时间:2023-09-11

        • <i id='NhPwd'><tr id='NhPwd'><dt id='NhPwd'><q id='NhPwd'><span id='NhPwd'><b id='NhPwd'><form id='NhPwd'><ins id='NhPwd'></ins><ul id='NhPwd'></ul><sub id='NhPwd'></sub></form><legend id='NhPwd'></legend><bdo id='NhPwd'><pre id='NhPwd'><center id='NhPwd'></center></pre></bdo></b><th id='NhPwd'></th></span></q></dt></tr></i><div id='NhPwd'><tfoot id='NhPwd'></tfoot><dl id='NhPwd'><fieldset id='NhPwd'></fieldset></dl></div>
        • <legend id='NhPwd'><style id='NhPwd'><dir id='NhPwd'><q id='NhPwd'></q></dir></style></legend>

            <tfoot id='NhPwd'></tfoot>

              <small id='NhPwd'></small><noframes id='NhPwd'>

              • <bdo id='NhPwd'></bdo><ul id='NhPwd'></ul>
                  <tbody id='NhPwd'></tbody>

                • JS原生非dialog信息提示框的示例代码,很简单的一个功能,点击问号,下边出现一个信息框,再次点击信息框消失,代码如下:
                  <!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>Document</title>
                      <style>
                          body {
                              height: 100vh;
                          }
                   
                          .msg-box {
                              width: 20px;
                              height: 20px;
                              line-height: 20px;
                              text-align: center;
                              background-color: #ccc;
                              position: relative;
                              border-radius: 50%;
                              color: #fff;
                              cursor: pointer;
                              top: 100px;
                              left: 50%;
                          }
                   
                          .msg {
                              width: 300px;
                              height: 100px;
                              color: #fff;
                              background-color: green;
                              position: absolute;
                              top: 150%;
                              right: -20%;
                              display: none;
                              /* 圆角 */
                              border-radius: 5px;
                          }
                   
                          .msg .arrow {
                              position: absolute;
                              top: -20px;
                              right: 4px;
                              width: 0;
                              height: 0;
                              font-size: 0;
                              border: 10px solid transparent;
                              border-bottom-color: red;
                          }
                      </style>
                  </head>
                   
                  <body>
                   
                      <div class="msg-box" data-show="0">
                          ?
                          <div class="msg">
                              <div class="arrow"></div>
                              信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容信息内容
                          </div>
                      </div>
                   
                  </body>
                   
                  </html>
                   
                  <script>
                      let box = document.querySelector('.msg-box')
                      let msg = document.querySelector('.msg')
                      // addEventListener() 事件监听器:监听元素的事件,并设置事件发生时触发的函数,以及事件流(冒泡、捕获)
                      box.addEventListener('click', (e) => {
                          // stopPropagation作用是阻止目标元素的冒泡事件,但是会不阻止默认行为
                          // console.log(e, 'e');
                          e.stopPropagation()
                          // e.target.dataset是指获取当前点击dom的值,若没有对应的值则取的是undefined
                          let show = e.target.dataset.show
                          // console.log(e.target.dataset, 'e.target.dataset.show');
                          if (Number(show)) {
                              // setAttribute() 方法添加指定的属性,并为其赋指定的值。
                              // 如果这个指定的属性已存在,则仅设置/更改值。
                              e.target.setAttribute('data-show', 0)
                              msg.style.display = 'none'
                          } else {
                              e.target.setAttribute('data-show', 1)
                              msg.style.display = 'block'
                          }
                      })
                      document.body.addEventListener('click', () => {
                          box.setAttribute('data-show', 0)
                          msg.style.display = 'none'
                      })
                  </script>
                   
                  上一篇:html点击按钮弹出页面获取值的实例代码 下一篇:没有了

                  相关文章

                • <i id='HQ0Dc'><tr id='HQ0Dc'><dt id='HQ0Dc'><q id='HQ0Dc'><span id='HQ0Dc'><b id='HQ0Dc'><form id='HQ0Dc'><ins id='HQ0Dc'></ins><ul id='HQ0Dc'></ul><sub id='HQ0Dc'></sub></form><legend id='HQ0Dc'></legend><bdo id='HQ0Dc'><pre id='HQ0Dc'><center id='HQ0Dc'></center></pre></bdo></b><th id='HQ0Dc'></th></span></q></dt></tr></i><div id='HQ0Dc'><tfoot id='HQ0Dc'></tfoot><dl id='HQ0Dc'><fieldset id='HQ0Dc'></fieldset></dl></div>

                        <bdo id='HQ0Dc'></bdo><ul id='HQ0Dc'></ul>

                      <tfoot id='HQ0Dc'></tfoot>

                      <small id='HQ0Dc'></small><noframes id='HQ0Dc'>

                    1. <legend id='HQ0Dc'><style id='HQ0Dc'><dir id='HQ0Dc'><q id='HQ0Dc'></q></dir></style></legend>