// 값을 가져오고자 하는 것과 같은 jsp페이지에서 코딩할 때
$('#myid option:selected').val();
$('select[name=myname]').val();
// id, name, class 전부 사용 가능
// js파일에서 값을 불러오고 싶을경우
$('.class').find('.selectclass option:selected').val();
// .class는 값을 품고있는 요소의 부모 이상의 요소
// .find 안의 값은 값을 품고있는 요소의 class, id, name
// ==> 두 과정을 통해 가져오고 싶은 값을 가진 요소를 특정한 뒤 .val()로 추출
'JavaScript' 카테고리의 다른 글
node.js) npm WARN config global --global, --local are deprecated. Use --location=global instead. 에러 (0) | 2022.07.04 |
---|---|
node.js ) 설치방법 (0) | 2022.07.01 |
Node, Express, React ) 대충 정리 (0) | 2022.06.02 |
jQuery ) 소개 (0) | 2022.05.30 |
Javascript ) 대충 정리 (0) | 2022.05.27 |