how to get value of input box without id and name field using javascript

后端 未结 5 2023
耶瑟儿~
耶瑟儿~ 2021-01-20 09:35

I have a form with 3 input box and all the input box does not have id, name field in it. So if i enter value in it, How can i check the value of input box without id and nam

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-20 10:12

    var inpObj = document.getElementsByTagName('input');
    for(var i in inpObj){
       if(inpObj[i].type == "text"){
             alert(inpObj[i].value);
        }
    }
    

    This code will alert all the input textfields.

提交回复
热议问题