2008년 3월 6일 목요일

[jquery] select box의 선택값 출력

<select id="cnt_type">
    <option value=1>1</option>
</select>



<script>
/////////////////////////////////////////
// case 1: 노가다
$("#cnt_type")
            .find("option[@selected]")
            .each(
            function(){
                alert ( this.value );
        })

/////////////////////////////////////////
// case 2: jQuery context 사용
alert ( $("#cnt_type > option:selected").val() );
</script>

댓글 없음:

댓글 쓰기