붙여 넣기 할 사람이 코드로 채워지는 텍스트 영역이 있습니다. 붙여 넣기는 &입니다. 이 텍스트 영역은 JQuery 및 .html()을 사용하여 "채워집니다". 다른 페이지의 예에 <div>
에서 나오는 "인구"로 : 인구 "보유"고JQuery .html() 정확한 html 코드를 인쇄하십시오.
사업부 "
<div id="populationhold">this is the html to copy</div>
를 다음"JQ의 마법은 클릭 "버튼 및 텍스트 영역을 채 웁니다"로 "
이제function updatefunction(){
$('#textarea').html($('#populationhold').val(); });
}
:
$('#button').click(function(){
updatefunction();
});
및 updatefunction 이 같은 비트입니다 나는 이런 식으로 뭔가 채워하려고하면 :
$('#textarea').html('this is the <br />html to copy');
들이게된다()뿐만 아니라 <br />
<br>
를 인쇄합니다. 나는 시도했다 (내 방식으로 <br \/>
으로 탈출했지만 시도하지 않았다.) HTML4 코드가 아닌 깨끗한 XHTML 코드를 생성해야한다.
다음 비트는 prob이지만 똑같지 만 약간 더 복잡한 - 따라서 위의이로 이끌 당신이 코드 예제에서 비트를 추가/삭제할 수 있습니다 내 사이트의 "사용자"로
:.
<div id="populationhold">
<div class="codebit1">this is the <br />html to copy</div>
\n<br/>\
<div class="codebit2">this is more <br />html to copy</div>
</div>
$('#button').click(function(){
$('#textarea').html($('#populationhold').val();
});
텍스트 영역을 채우기 괜찮 및 작품의 "90 %"는 다음과 같습니다.
$('#deletebutton').click(function(){
$('.codebit1').remove();
// This removes .codebit1 from #populationhold and runs the update to ummm update the textarea with the update function
// Note: remove() is OK in this case as #codebit1 is totally dynamically created
updatefunction();
});
여기에서 질문은 삭제해야 할 비트를 삭제/삭제할 수 있습니다. 따라서 "90 %"는 제거 할 수 있지만, "지금 고아"를 없애려면 어떻게해야합니까? \n<br/>\n
#textarea . OK \n<br/>\n
없이도이 작업을 수행 할 수 있지만 눈에 "깔끔하지 않은"코드를 복사하여 \n<br/>\n
이있는 이유는 - \n<br/>\n
도 실제로 코드를 복사 할 때 사용자가 적절한 레이아웃을 얻는 것을 보장합니다.
올바른 doctype을 사용하고 있습니까? –
@Timo 나는 똑같은 것을 물어 보려고하고 있었다. ... –