티스토리 뷰
개발하다 input을 select로 서로 변환 시켜줘야 하는 상황이 발생했다.
평소처럼 둘다 만들어서 show/hide하기에는
연관되는 작업들이 많아서
다른방법이 없을까 찾아보다
replaceWith 라는 기능이 있어서 포스팅 한다.
공식 api : http://api.jquery.com/replacewith/
사용법은 공식 api에도 잘나와 있지만
주의점은 변환 대상 element는 삭제되고
1. $(변경될 element selector).replaceWith(변경될 element html); 2. $(변경될 element selector).replaceWith(function(){ return $('',attribute) }); ex ) $('#abc').replaceWith(""); $('#abc').replaceWith(function(){ return $('',{type : 'text', class: 'input-text'}) });
replaceWith한 element로 변환되니
속성값등 필요한 정보는 꼭 다시 적어줘야 한다.
댓글
최근에 올라온 글
최근에 달린 댓글
글 보관함
- Total
- Today
- Yesterday
TAG
- git log
- git reflog
- java
- intranet 설치방법
- indexeddb
- Security
- Git
- 몽고디비
- yyyy-MM-dd
- GitHub
- sprign security
- Spring
- getaddrinfo ENOTFOUND localhost
- 2장요약
- jquery
- replaceWith
- xcrun
- 자료형
- cronexpression
- 스프링시큐리티
- 인테리어 시뮬레이터
- springsecurity
- javascript
- 중복 호출
- fullcalendar
- mongoDB
- errordocument
- array
- remember-me
- 중복 실행