2017-03-24 19 views
-1
<input type="text"id="text111" name="text111"> 

이 줄이 있으며 텍스트 상자의 오른쪽에 단추를 삽입하려고합니다 ... JS에서 어떻게 할 수 있습니까?버튼을 입력 상자 가까이에 삽입

크롬 확장입니다.
ID의 모든 인스턴스를 찾아서 삽입하려고합니다 ...하지만 어떻게해야합니까?

+0

에 주석 && CSS는 –

답변

1

가 사용 .insertAdjacentHTML()는, 세부 사항은 HTML과 쉬운 것 발췌문

SNIPPET

// Reference the textbox 
 
var in111 = document.getElementById('text111'); 
 

 
/* use insertAdjecentHTML() method 
 
|| The first parameter is the position of insertion 
 
|| The second parameter is the text that will be rendered into 
 
|| HTML. 
 
*/ 
 
in111.insertAdjacentHTML('afterend', '<button id="btn">Button</button>');
<input type="text" id="text111" name="text111">

+0

작품 솔직히합니다, 감사합니다! –

+0

문제가 해결되면 ✔를 클릭하십시오. – zer00ne