Difference between “[removed]” and “.value” in JS

前端 未结 3 1021
死守一世寂寞
死守一世寂寞 2020-11-27 22:03

I am confused on what is the difference between .innerHTML and .value in JavaScript. Here is my code:


Input string: &         


        
3条回答
  •  無奈伤痛
    2020-11-27 22:20

    value refers to the value of an input element (or textearea)

    
    

    value would be "hello world" (or any value typed inside)


    innerHTML refers to the contents inside an HTML element.

    All tags and their children are include in innerHTML. All this is part of innerHTML.

    innerHTML of the div tag would be the string:

      '
         All tags and their children are include in innerHTML.
      
      All this is part of innerHTML.'
    

提交回复
热议问题