search

Home  >  Q&A  >  body text

javascript - I am a little confused, why can I directly use checked=true to add effects to tags in js?

For example: I need to use js to add a selected effect to the button.

Why can you directly use op.checked = true? to add the selected effect in js? Why don't you need to add a style in the middle? If it is color, it is like this op.style.color = "red" ?

阿神阿神2699 days ago743

reply all(2)I'll reply

  • 迷茫

    迷茫2017-06-26 10:57:27

    Add css attributes after style. checked is an attribute of input, so there is no need to add style.

    reply
    0
  • 阿神

    阿神2017-06-26 10:57:27

    In fact, it’s the same if you write it directly in the html tag,

    <input type="checkbox" checked/>
    <span style="color:red"></span>

    You write directly

    <span color="red"></span>

    It must be ineffective, one is the attribute of tag and the other is style

    reply
    0
  • Cancelreply