본문 바로가기

sundries

1-17 select option selected

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<script src ="../js/jquery-3.2.1.js"></script>


</head>

<script>


$(function(){

//2초후 코드 실행

setTimeout(function(){

//변수를 선언

//var value = $('select> option:selected').val

var value = $('option:selected').val();

//출력

alert('선택하신 메뉴는 ' + value + '입니다');

}, 2000);

});

</script>

<body>

<select size = 5>

<option>김밥</option>

<option selected>짜장면</option>

<option>냉면</option>

<option>비빔밥</option>

<option>돈까스</option>

</select>

</body>

</html>