VLD*_*NDN -1 html javascript jquery html5
我有5个输入框,每个输入框都有不同的值..我如何合并输入框的值并进行比较,然后提醒或做某事..
例:
<form>
<input id="input1" type="text">
<input id ="input2" type = "text"/>
<input id ="input3" type = "text"/>
<input id = "input4" type = "text"/>
<input id = "input5" type = "text"/>
</form>
var input1 = document.getElementById('input1').value;
var input2 = document.getElementById('input2').value;
var input3 = document.getElementById('input3').value;
var input4 = document.getElementById('input4').value;
var input5 = document.getElementById('input5').value;
var wordsConcat = input1.concat(input2,input3,input4,input5);
Run Code Online (Sandbox Code Playgroud)
//合并后将单词比作SAMPLE;
你已经标记了jQuery,所以我假设你可以使用它.
您可以将每个输入映射到一个值,然后join()使用空字符串将它们组合在一起:
var vals = $('input').map(function(){
return this.value;
}).get().join('');
Run Code Online (Sandbox Code Playgroud)