jquery 다중 선택 상자 값 가져오기

902 단어 jqueryfunction
jquery 다중 선택 상자 값:
		<select id="single">
			<option>
				Single
			</option>
			<option>
				Single2
			</option>

		</select>
		<select id="multiple" multiple="multiple">
			<option selected="selected">
				Multiple
			</option>
			<option>
				Multiple2
			</option>

			<option selected="selected">
				Multiple3
			</option>
		</select>
		<script> 
		function displayVals() { 
				var singleValues = $("#single").val(); 
				var multipleValues = $("#multiple").val() || []; 
				$("p").html("<b>Single:</b> " + singleValues + " <b>Multiple:</b> " + multipleValues.join(", ")); 
			}

		$("select").change(displayVals); displayVals();

		</script>

좋은 웹페이지 즐겨찾기