从jsp页面中的以下三个下拉菜单中,我想要附加所有选定的值并存储在单个字符串变量中。
<Select id="one" >
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select><br>
<Select id="two" >
<option value="x">x</option>
<option value="y">y</option>
<option value="z">z</option>
</select><br>
<Select id="three" >
<option value="m">m</option>
<option value="l">l</option>
<option value="n">n</option>
</select><br>
答案 0 :(得分:0)
var str = "";
$( "select option:selected" ).each(function() {
str += $( this ).val() + " ";
});
答案 1 :(得分:0)
var myString = "";
$('select').change(function(){
myString = $('#one').val() + $('#two').val() + $('#three').val();
$('div').text(myString);
});