페이지가 2로 나누어 진 개인 웹 사이트를 만들고 있습니다. 왼쪽을 클릭하면 왼쪽 부분이 오른쪽으로 확장되고 그 반대의 경우도 마찬가지입니다.JS 초급 단계 :이 JSfiddle을 복제 할 수 없습니다.
버튼을 클릭하면 버튼이 모든 것을 재설정 할 수 있습니다. 그것은이 JSFiddle에서 잘 작동 : http://jsfiddle.net/davidThomas/CFNUJ/1/
그러나 나는 (http://guillaumeb.com/jsfiddle/split.html)
은 "모두보기"버튼을 아무것도하지 않습니다 ...
이 또한 내가 눈치 복제 할 수 JQuery와의 최신 버전 원래 예제처럼 v 1.x를 사용하도록 전체 작업을 중단하십시오.내 JS 기술은 매우 제한적입니다.
$('#left-bg, #right-bg').click(
function(){
$(this).animate({'width': '100%'},600).siblings().animate({'width':'0'},600);
$('<button class="show">Show all</button>')
.appendTo('#wrapper');
});
$('.show').live('click',
function(){
$('#left-bg').animate(
{
'width': '50%'
},600);
$('#right-bg').animate(
{
'width': '50%'
},600);
$(this).remove();
});
#left-bg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
background-color: #000;
color: #fff;
width: 50%;
margin: 0;
}
#right-bg {
position: absolute;
right: 0;
bottom: 0;
top: 0;
background-color: #fff;
color: 000;
width: 50%;
margin: 0;
}
.show {
position: absolute;
bottom: 0;
left: 50%;
margin-left: -2.5em;
width: 5em;
}
<div id="wrapper">
<div id="left-bg">
<p>Left stuff</p>
</div>
<div id="right-bg">
<p>Right stuff</p>
</div>
</div>
<div id="wrapper">
<div id="left-bg">
<p>Left stuff</p>
</div>
<div id="right-bg">
<p>Right stuff</p>
</div>
</div>
코드 fomr를 빌려 어디서든 JQuery와 수입하고 있는가? –
그는 관련없는 코드를 삭제했을 가능성이 높습니다. 그 이유는 그의 서식이 너무 어리 석다는 것입니다. – tipsfedora
'live()'는 오래 전에 사용되지 않았기 때문에 중단됩니다. – charlietfl