이 문제를 처리하기 위해 구조를 다시 생각해 보겠습니다. 대부분의 작업은 스왑 기능을 롤링하는 대신 jQuery로 처리 할 수 있습니다. 피들 (Fiddle)을 포함하여 질문 할 때 대답을 빨리 얻을 수있는 좋은 방법입니다. 여기에 attr
대신 jQuery 1.7의 prop
메서드를 사용해야합니다.
http://jsfiddle.net/txbqX/3/
jQuery를 사용하면
//when main image is clicked, show it in colorbox
$('#foo a').colorbox();
//when thumb is clicked, set main image to it
$('div#thumbs img').click(function() {
$('#foo a').prop('href', $(this).prop('src'));
$('#foo img').prop('src', $(this).prop('src'));
return false; //stop link from navigating
})
간체 HTML
<div id="foo" >
<a href="http://www.artdesigngroup.co/images/tv-frames/01.jpg">
<img src="http://www.artdesigngroup.co/images/tv-frames/01.jpg" width="304" height="304" name="Display" id="display" />
</a>
</div>
<br />
<div id="thumbs">
<img src="http://www.artdesigngroup.co/images/tv-frames/01.jpg" width="56" height="56" />
<img src="http://www.artdesigngroup.co/images/tv-frames/02.jpg" width="56" height="56" />
<img src="http://www.artdesigngroup.co/images/tv-frames/03.jpg" width="56" height="56" />
<img src="http://www.artdesigngroup.co/images/tv-frames/04.jpg" width="56" height="56" />
<img src="http://www.artdesigngroup.co/images/tv-frames/05.jpg" width="56" height="56" />
</div>
당신은 이전의 질문에 (좋은) 몇 가지 답변을 받아 들여야 원하는 것을 얻을 수 있습니다. 그것은 SO가 repuation을 관리하는 방법입니다. http://stackoverflow.com/faq#reputation – mrtsherman