Get the value in an input text box

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

    You can only select a value with the following two ways:

    // First way to get a value
    value = $("#txt_name").val(); 
    
    // Second way to get a value
    value = $("#txt_name").attr('value');
    

    If you want to use straight JavaScript to get the value, here is how:

    document.getElementById('txt_name').value 
    

提交回复
热议问题