반응형
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input id="testID" class="testClass" name="testName" value="테스트"/>
</body>
</html>
input의 value 기준으로 작성하였습니다.
$('#testID').val(); // id 선택자가 기준일 땐 #을 붙여줍니다.
$('.testClass').val(); // class 선택자가 기준일 땐 .을 붙여줍니다.
$('[name=testName]').val(); // id, class 외엔 이런식으로 가져올 수 있습니다.
$('[test=testName]').val(); // 만약 test
결과값을 잘 가져온것을 볼 수 있습니다.
반응형
'...' 카테고리의 다른 글
[CA] 동기(Blocking)와 비동기(Non-Blocking) (2) | 2021.01.24 |
---|---|
[JS] 정규식 예제들 (0) | 2021.01.21 |
[Js] 자바스크립트 한글, 영어, 숫자 체크하기 (0) | 2021.01.21 |
[Spring] ApplicationContext와 WebApplicationContext (0) | 2021.01.20 |
[Spring] root-context와 servlet-context (2) | 2021.01.20 |