Difference between val() and text()

前端 未结 4 1415
说谎
说谎 2020-11-22 11:50

What the difference between jQuery\'s functions val() and text()?

Where would you use one over the other?

4条回答
  •  忘了有多久
    2020-11-22 12:31

    val() is used to fetch value from all html input types like(checkbox,text,etc),where user have an option to input value. Ex:-

     
     bike

    where as text() is used to fetch value from the html elements where user will not interact like (p,div etc)

        

    Hi how are u??

    Debendra

提交回复
热议问题