문제
프로젝트와 이름이 다른 몇 가지 다른 DIV가 있습니다. 각각은 고유 한 이름을 가지고 있으며 사용자가 하나를 클릭하면 해당 페이지를 popupContainer
div. 어떤 이유로 든 그것은 전화하지 않습니다.
이것은 jQuery입니다 :
$(document).ready(function(){
//Find & Open
$(".projectThumb").click(function(){
htmlName = $(this).find("img").attr("name");
$("#popupContainer").load(htmlName + ".html");
});
//Close property
$("a.close").live("click", function(){
$("#popupContainer").empty();
});
});
이것은 HTML입니다.
<div id="content">
<div class="projectThumb">
<img src="/img/aeffect_button_static.gif" width="146" height="199" class="button" name="aeffect" alt="" />
<p class="title">A.EFFECT: Film Poster</p>
</div>
<div class="projectThumb">
<img src="/img/lova_button_static.gif" width="229" height="199" class="button" name="lova" alt="" />
<p class="title">Lova – Summer 07’ – Titles</p>
</div>
</div>
<div id="popupContainer"></div>
해결책
첫 번째 클릭 함수를 닫지 않고 ready(function(){...})
올바르게 :
$(document).ready(function(){ // <-- added missing open parens
//Find & Open
$(".projectThumb").click(function(){
htmlName = $(this).find("img").attr("name");
$("#popupContainer").load(htmlName + ".html");
}); // <-- added needed closing function
//Close property
$("a.close").live("click", function(){
$("#popupContainer").empty();
});
});
다른 팁
꼬리표
<img ... >
속성 "이름"(양식 및 구성 요소 만)이 없으며 "ID"를 사용하십시오 :)
첫 번째 클릭 기능을 닫지 않으면 :
$(document).ready(function){
//Find & Open
$(".projectThumb").click(function(){
htmlName = $(this).find("img").attr("name");
$("#popupContainer").load(htmlName + ".html");
}); <-- needed
//Close property
$("a.close").live("click", function(){
$("#popupContainer").empty();
});
});
제휴하지 않습니다 StackOverflow