저는 div의 내용을 click 이벤트에 바인드 된 새 내용으로 바꾸려고합니다. 내가 대신이 일하고 html()
의의 appendTo()
를 사용하지만 기존의 컨텐츠를 취소해야하는 경우jquery div content html()
그래서 약간은
저는 div의 내용을 click 이벤트에 바인드 된 새 내용으로 바꾸려고합니다. 내가 대신이 일하고 html()
의의 appendTo()
를 사용하지만 기존의 컨텐츠를 취소해야하는 경우jquery div content html()
그래서 약간은
을해야처럼이 작동하지 않는 이유를 혼란 스러워요 당신 content
대신 selector
및 selector
을 사용하는 경우 대신 #
과 ID selctor를 사용해야합니다. 당신이 당신이 바이올린에 약간의 실수가 이런 식으로
function showitnow() {
var div_data = "<div ><a href='XXX'>XXX</a></div>";
$("#test1").html(div_data);
}
$("#button1").click(function() {
showitnow();
});
을 할 수있는, 즉 다음과 같이해야합니다 : http://jsfiddle.net/pCckh/3/
function showitnow() {
var div_data = "<div ><a href='XXX'>XXX</a></div>";
$("#test1").html(div_data);
// ^---selector----^----------your content
}
$("#button1").click(function() {
showitnow();
// ^----------------remove the var and just call the function when click the button
});
어쩌면 u는이 시도 할 수 있습니다 ..
부모와 자식으로 JQuery를 재생 ..
<div id="Destination">
<div class="child_content"> item 1 </div>
<div class="child_content"> item 2 </div>
</div>
<div id="Source">
<div class="child_content"> item 1 </div>
<div class="child_content"> item 2 </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#Source .child_content").click(function(){
$(this).parent().remove();
$(this).appendTo("#Destination");
});
});
</script>
희망이 helpfull ..
Please have a look! 예상 결과 ... 같은 예에서 요구
만 약간 수정.
<div id = 'div_data'>
<button id="button1">BUTTON1</button>
div>
<div id="test2"></div>
jsfiddle 링크와 함께 질문을 뒷받침하는 코드를 입력해야합니다. – Adil