본문 바로가기

Programming diary

4. August 23, 2020

오늘의 배움 attr

 

placeholder 값을 DB에 있는 값으로 넣고 싶을 때(대체).

 

html 엔 플레이스홀더 태그만 넣어주고

<input type="text" class="form-control" id="new_post_eng" placeholder='default' readonly />

 

 

button에 onclick 기능으로 이 함수를 연결할때 (post_eng)를 넘겨주고 있는 상황. 

<button id="edit_card" onclick="editCard('${post_eng}', '${post_kor}', '${post_memo}')" data-toggle="modal" data-target="#exampleModal" ><i class="fas fa-eraser fa-2x" ></i></button>

 

현재 아래 스크립트는 function에 기록되어 있는 것 중에 하나고, 스크립트에서 html 아이디값으로 input 창을 불러와 플레이스 홀더 값(넘어온 post_eng)을 attr로 준다.

$('#new_post_eng').attr('placeholder', post_eng );

 

 

 

 

'Programming diary' 카테고리의 다른 글

8. September 1, 2020  (0) 2020.09.01
7. August 30, 2020 <8주간의 스파르타코딩클럽 후기>  (0) 2020.08.30
6. August 26, 2020  (0) 2020.08.26
5.2 August 25, 2020  (0) 2020.08.25
3. August 20, 2020  (0) 2020.08.20