applan의 개발 이야기

[TIP] Jquery - 다양한 입력 태그 알아내기 본문

개발/Dev.

[TIP] Jquery - 다양한 입력 태그 알아내기

applan 2023. 1. 6. 16:17
728x90
웹을 개발하다보면 TextArea 를 사용하는 일이 생기기 마련. 
Jquery에서 Input, TextArea 값을 가져오는 방법을 적어둔다.
* TextArea는 항상 까먹어서 검색한다..

💡 알아둘 것

원하는 태크를 선택하는 다양한 방법들

See the Pen Untitled by 민수 (@applan_siepe) on CodePen.

😃 방법

1. Input

// SET
$("원하는 InputBox").val("원하는 값");
// GET
$("원하는 InputBox").val();

2. radio

// SET
$("원하는 radio").prop('checked',true);	// 선택
$("원하는 radio").prop('checked',false);	// 취소
// GET
$("원하는 radio").val();

 

3. checkBox

// SET
$("원하는 checkBox").prop('checked',true);	// 선택
$("원하는 checkBox").prop('checked',false);	// 취소
// GET
$("원하는 checkBox").val();

4. textArea

// SET
$("원하는 textArea").val("원하는 값");
// GET
$("원하는 textArea").val();

 

728x90
Comments