티스토리 뷰
개발하다 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
- xcrun
- 중복 호출
- jquery
- java
- 2장요약
- git log
- remember-me
- 인테리어 시뮬레이터
- indexeddb
- 몽고디비
- 중복 실행
- javascript
- yyyy-MM-dd
- errordocument
- getaddrinfo ENOTFOUND localhost
- 자료형
- git reflog
- cronexpression
- replaceWith
- sprign security
- intranet 설치방법
- GitHub
- Git
- Spring
- springsecurity
- Security
- mongoDB
- array
- 스프링시큐리티
- fullcalendar