Case: a lot of string concatenation results achieved
Click the button, string concatenation, the final effect is a string, str
There are a lot of input, type button and have to divide text, need to find inputs [i] .value is the text of
So use! = "Button", push it into the condition str, it is str.push (inputs [i] .value)
console.log display, you can use str.join stitching, add | more clearly
Briefly, the way to get traversing inputs [i] .value not buttons, Push into str, finally join into str
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>title</title> </head> <body> <input type="button" value="拼接吧" id="btn" /><br /> <input type="text" value="" /><br /> <input type="text" value="" /><br /> <input type="text" value="" /><br /> <input type="text" value="" /><br /> <input type="text" value="" /><br /> <script src="common.js"></script> <script> " document.getElementById (recommended way to use an array of splicing a lot of strings// BTN " ) .onclick = function () { var STR = []; // get all text boxes var Inputs = document.getElementsByTagName ( " INPUT " ) // each text box of the value attribute for ( var I = 0 ; I < inputs.length; I ++ ) { IF (Inputs [I] .Type =! " Button " ) { str.push (Inputs [I] .Value); } } the console.log (str.join ("|"));//字符串 }; </script> </body> </html>