简体   繁体   中英

print or show current value of variable in console.log

With the below; I am attempting to capture form field contents on click of submit button. However when I go to test it and console.log the variable I just get the HTML of the form field. Any pointers. Or I get uncaught reference error, the variable is not defined.

Mark-Up wise: I'm using input type text and input type radios.

$(document).ready(function(){ 

         $('#submitS').click(function(){

         var firstName01 = document.getElementById('firstName').value;

         var firstName02 = document.getElementById('firstName2').value;

         var lastName01 = document.getElementById('lastName').value;
         var lastName02 = document.getElementById('lastName2').value;

         var iphone01 = document.getElementById('iphone').value;
         var android01 = document.getElementById('android').value;

         var iphone02 = document.getElementById('iphone2').value;
         var android02 = document.getElementById('android2').value;
     });

});

尝试使用.textContent而不是.value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM