Home  >  Q&A  >  body text

id选择器和类选择器的用法除了标签设置和#区别外还有 哪些?

phpcn_u251phpcn_u2512832 days ago933

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:26:34

    What are the usages of id selector and class selector besides label setting and #difference? -PHP Chinese website Q&A-What are the usages of id selector and class selector besides label setting and #? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-21 15:51:12

    在同一个页面内,不允许有相同名字的id对象出现,但是允许相同名字的class。这样,一般网站分为头,体,脚部分,因为考虑到它们在同一个页面只会出现一次,所以用id,其他的,比如说你定义了一个颜色为red的class,在同一个页面也许要多次用到,就用class定义。另外,当页面中用到js或者要动态调用对象的时候,要用到id,所以要根据自己的情况运用。自己的语言。
    但document的方法中有getElementById()这个方法倒是只能用id的.

    reply
    0
  • Cancelreply