아래 코드를 작동시키는 데 문제가 있습니다. 기본적으로 마우스 오버시 본체에 추가하여 요소를 이동하려고했습니다. 내 코드가 뭐가 잘못 됐어?이 요소를 추가하십시오
감사
<div class="wrp">
<p>this is a wrap</p>
<p><img src="myimg.jpg" /></p>
</div>
<div class="wrp">
<p>this is a wrap2</p>
<p><img src="myimg.jpg" /></p>
</div>
<div class="wrp">
<p>this is a wrap3</p>
<p><img src="myimg.jpg" /></p>
</div>
<script type="text/javascript">
$(".wrp").hover(function(){
$("img", this).appendTo("body");
});
</script>
예상 출력 : 당신이 우리에게 실제로 발생한 출력을 보여 주었다 경우
<html>
<head/>
<body>
...
<img src="myimg.jpg" />
</body>
</html>
정확히 같습니다. [Here] (http://jsfiddle.net/hCC2H/)는 물론 이미지가 깨진 jsfiddle이지만 여전히 원하는 작업을 수행 할 수 있습니다. – Pointy
나는'.wrp'와'이미지 '를 움직이기 때문에 이미지가 몸과 이미지로 옮겨 질 것이므로'$ (this) .find ('img ') .appendTo ('body')' – Val
@Val 아니,'$ ('img', this)'는 - $ (this)와 동일 함 .find ('img') – Pointy