How to get text box value in JavaScript

前端 未结 15 1769
面向向阳花
面向向阳花 2020-12-07 14:43

I am trying to use JavaScript to get the value from an HTML text box but value is not coming after white space

For example:



        
15条回答
  •  感动是毒
    2020-12-07 15:07

    Your element does not have an ID but just a name. So you could either use getElementsByName() method to get a list of all elements with this name:

    var jobValue = document.getElementsByName('txtJob')[0].value  // first element in DOM  (index 0) with name="txtJob"
    

    Or you assign an ID to the element:

    
    

提交回复
热议问题