Get the value in an input text box

前端 未结 12 600
你的背包
你的背包 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:25

    You can get the value attribute directly since you know it's an element, but your current usage of .val() is already the current one.

    For the above, just use .value on the DOM element directly, like this:

    $(document).ready(function(){
      $("#txt_name").keyup(function(){
        alert(this.value);
      });
    });
    

提交回复
热议问题