문서의 선택한 두 판 사이의 차이를 보여줍니다.
|
wiki:javascript:jquery:jquery_note:jquery_change_method [2023/01/27 09:40] emblim98 만듦 |
wiki:javascript:jquery:jquery_note:jquery_change_method [2023/01/27 12:44] (현재) emblim98 |
||
|---|---|---|---|
| 줄 19: | 줄 19: | ||
| 콘텐츠가 변경된 후 해당 필드가 focus를 잃을 때 change 이벤트가 발생합니다.\\ | 콘텐츠가 변경된 후 해당 필드가 focus를 잃을 때 change 이벤트가 발생합니다.\\ | ||
| + | <code javascript> | ||
| + | // ' | ||
| + | $(document).on(' | ||
| + | // | ||
| + | |||
| + | // 선택한 option의 value에 지정된 값을 변수에 대립 | ||
| + | //let selectedAccountVal = $(' | ||
| + | let selectedAccountVal = $(' | ||
| + | |||
| + | // 선택한 option의 value의 값에서 첫 번째 문자만 추출하고, | ||
| + | let firstChar = selectedAccountVal.substring(0, | ||
| + | $(this).siblings(' | ||
| + | $(this).siblings(' | ||
| + | // | ||
| + | |||
| + | console.log(firstChar); | ||
| + | |||
| + | if (firstChar === ' | ||
| + | { | ||
| + | $(this).siblings(' | ||
| + | $(this).siblings(' | ||
| + | $(this).siblings(' | ||
| + | |||
| + | } | ||
| + | else if (firstChar === ' | ||
| + | { | ||
| + | $(this).siblings(' | ||
| + | $(this).siblings(' | ||
| + | $(this).siblings(' | ||
| - | + | } | |
| - | + | else if (firstChar === ' | |
| - | + | { | |
| - | + | $(this).siblings(' | |
| - | + | $(this).siblings(' | |
| - | + | $(this).siblings(' | |
| - | + | } | |
| - | + | else if (firstChar === ' | |
| - | + | { | |
| - | + | $(this).siblings(' | |
| - | + | $(this).siblings(' | |
| - | + | $(this).siblings(' | |
| - | + | } | |
| - | + | }); | |
| - | + | </ | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||