Get the value in an input text box

前端 未结 12 808
你的背包
你的背包 2020-11-22 07:54

What are the ways to get and render an input value using jQuery?

Here is one:

12条回答
  •  庸人自扰
    2020-11-22 08:29

    There is one important thing to mention:

    $("#txt_name").val();
    

    will return the current real value of a text field, for example if the user typed something there after a page load.

    But:

    $("#txt_name").attr('value')
    

    will return value from DOM/HTML.

提交回复
热议问题