JQuery와 :왜이 간단한 jQuery 블록이 작동하지 않습니까?
$(document).ready(function() {
$("#links .button").click(function() {
var id = $(this).attr("id") + "-fade";
$("#sliding-blocks").fadeOut(100);
$("#" + id).fadeIn(300);
});
});
그리고 간단한 HTML : 비 간단한 HTML 명명 규칙 같은 "페이드"다음 #links
및 #sliding-blocks
있지만, 모든 개 항목이 포함
<table id="links">
<tr>
<td>
<div id="projects" class="button">
Projects
</div>
</td>
</tr>
</table>
<table id="sliding-blocks">
<tr>
<td>
<span id="projects-fade" class="block">
<img class="icon" src="github.png" height="20" width="20" />
</span>
</td>
</tr>
</table>
.
나는 일할 수있는 어떤 것도 얻을 수 없습니다 (내가 할 수있는 것조차도). 그리고 네, jQuery를로드했습니다.
솔루션 :
$(document).ready(function() {
var blocks = ["projects-fade", "blog-fade", "online-fade", "resume-fade"];
$("#links .button").click(function() {
var id = this.id + "-fade";
$("#sliding-blocks").fadeOut(100,function() {
$.each(blocks, function() {
$("#" + this).hide();
});
$("#" + id).show();
$(this).fadeIn(300);
});
});
});
표시하려는 요소를 포함하는 테이블을 페이드 아웃하고 있습니다. – frictionlesspulley