前端札记 前端札记
首页
    • 前端
    • 服务器
    • 其他
  • 分类
  • 归档
  • 标签
GitHub (opens new window)

Xin

面朝大海,春暖花开
首页
    • 前端
    • 服务器
    • 其他
  • 分类
  • 归档
  • 标签
GitHub (opens new window)
  • HTML
    • 《HTML》笔记
    Xin
    2022-03-18
    目录

    HTML

    # 页面获取getElementsByClassName()并对其操作

    • 报错<Uncaught TypeError: document.getElementsByClassName(...).方法名is not a function

      // 解决方法:
      // 这是因为选择器没有正确选择元素对象
      document.getElementsByClassName(...)捕捉到的是该类名元素的数组
      // 正确的访问方式应该是:
      document.getElementsByClassName(...)[0].方法名...
      
      // ------Example------
            document
              .getElementsByClassName(index)[0]
              .scrollIntoView({ behavior: 'smooth', inline: 'nearest' });
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10

    # 表格

    <table border="1px">
        <caption>标题信息</caption>
        <tr>
            <th>表头1</th>
            <th>表头2</th>
        </tr>
        <tr>
            <td>单元格1</td>
            <td>单元格2</td>
        </tr>
    </table>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    • th 表头 th内部的文字样式为 居中+粗体

    • tr 行

    • td 单元格

    • [th]、[td] 都可以跨列[左右属于列]操作(colspan)、跨行[上下属于行]操作(rowspan)

    # 特殊符号

    • 小于 &lt;
    • 大于&gt;
    编辑 (opens new window)
    #HTML
    上次更新: 2024-07-15 23:22:40
    Theme by Vdoing | Copyright © 2021-2025
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式