Question

I have a few different divs with different projects and names. Each one has a unique name, and I would like that when a user clicks on one, that it loads the appropriate page into the popupContainer div. For some reason it is not calling though.

This is the 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();
        });
});

This is the 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 &ndash; Summer 07&rsquo; &ndash; Titles</p>
    </div>
</div>
<div id="popupContainer"></div>
Was it helpful?

Solution

You're not closing your 1st click function and you're not opening the ready(function(){...}) correctly either:

$(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();
 });
});

OTHER TIPS

Tag

<img ... >

has no attribute "name" (only form and its components), use "id" :)

Your not closing your 1st click function:

$(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();
 });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top