V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Liang
V2EX  ›  程序员

selected or selected="selected"

  •  
  •   Liang · Jun 2, 2016 · 3096 views
    This topic created in 3626 days ago, the information mentioned may be changed or developed.
    你会怎么用,哪种标准?
    13 replies    2016-06-02 22:15:08 +08:00
    halfer53
        1
    halfer53  
       Jun 2, 2016
    一般 selected == true
    nigelvon
        2
    nigelvon  
       Jun 2, 2016
    selected="selected"这个标准
    https://www.w3.org/TR/html-markup/option.html
    skydiver
        3
    skydiver  
       Jun 2, 2016 via iPad
    前面是 html5 ,后面是 xhtml ,不同的标准
    SourceMan
        4
    SourceMan  
       Jun 2, 2016
    标准不一样,建议直接 selected
    aivier
        5
    aivier  
       Jun 2, 2016 via Android
    一直是 selected ,感觉后者有点啰嗦?
    Slienc7
        6
    Slienc7  
       Jun 2, 2016
    只有 XHTML 要求 selected="selected"
    其他随意,一般习惯 selected 直接用。
    ChiangDi
        7
    ChiangDi  
       Jun 2, 2016 via Android
    一般我喜欢字数少的
    Tonni
        9
    Tonni  
       Jun 2, 2016
    > selected = "selected" or "" (empty string) or empty #

    From https://www.w3.org/TR/html-markup/option.html#option.attrs.selected
    XianZaiZhuCe
        10
    XianZaiZhuCe  
       Jun 2, 2016 via iPhone
    1
    Dreawer
        12
    Dreawer  
       Jun 2, 2016
    @Dreawer http://www.dreawer.com/resource/image/A058C77EFA6B8E5AE05331398D9736C7.png

    详见 MDN ,需要的是一个布尔值。 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option

    不能上传图片什么鬼。。貌似也不能修改自己的回答啊。。。。
    Slienc7
        13
    Slienc7  
       Jun 2, 2016
    @Dreawer
    写的是 "this Boolean attribute" ,不是说需要一个“布尔值”
    参考这个: https://stackoverflow.com/questions/7089584/html-why-boolean-attributes-do-not-have-boolean-value
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1761 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 16:18 · PVG 00:18 · LAX 09:18 · JFK 12:18
    ♥ Do have faith in what you're doing.