2013-10-03 39 views
0

我有一切在html和jquery中工作,但我需要做的是分配並追加一個數字,以使唯一ID與Repeater字段一起工作。這是我在HTMLCSSjquery。有沒有辦法在html#expand ID末尾附加一個唯一編號(如1或2 ...),jQuery使用ACF爲jQuery添加唯一的id或數字ID使用ACF

這裏是我從你們這裏幫助代碼:

#expand-1 .bio-pic2, #expand-2 .bio-pic2 { 
    position:absolute; 
    top:0; 
    left:0; 
} 
#expand-1, #expand-2 { 
    position:absolute; 
    width:1000px; 
    border: 1px solid black; 
    display: none; 
    background-color:#ffffff; 
    z-index:9999; 
    height:323px; 
} 
.bio-pic2 img { 
    position:absolute; 
    top:0; 
    left:0; 
    width:323px; 
} 
.testimonial { 
    position:absolute; 
    top:333px; 
    left:0; 
    font-size:15px; 
} 
.desc { 
    position:absolute; 
    top:10px; 
    left:333px; 
} 
.bio-pic { 
    float:left; 
    cursor: pointer; 
    z-index:9998; 
    margin:0 5px 0 0; 
} 
<div id="expand-1"> 
    <div class="test"> 
     <div class="bio-pic2"> 
      <img src="http://www.brent-ransom.com/photo-img.jpg" /> 
      <div class="bio-nt"> 
        <h2>Name</h2> 

        <h3>Position</h3> 

      </div> 
     </div> 
     <div class="testimonial">A testimonial!</div> 
    </div> 
    <div class="desc">This is a paragraph of text.</div> 
</div> 
<div id="img-1" class="bio-pic"> 
    <img src="http://www.brent-ransom.com/photo-img.jpg" /> 
</div> 
<div id="expand-2"> 
    <div class="test"> 
     <div class="bio-pic2"> 
      <img src="http://brent-ransom.com/photo2-img.jpg" /> 
      <div class="bio-nt"> 
        <h2>Name</h2> 

        <h3>Position</h3> 

      </div> 
     </div> 
     <div class="testimonial">A testimonial!</div> 
    </div> 
    <div class="desc">This is a paragraph of text.</div> 
</div> 
<div id="img-2" class="bio-pic"> 
    <img src="http://brent-ransom.com/photo2-img.jpg" /> 
</div> 
$(".bio-pic").click(function (e) { 
    e.stopPropagation(); 
    //$('.bio-pic2').toggle("slow"); 
    var menu = $("#expand-"+$(this).attr("id").split("-")[1]); 
    $(menu).show().animate({ 
     width: 500 
    }, 1000); 
}); 
$("#expand-1, #expand-2").click(function() { 
    $(this).animate({ 
     width: 0 
    }, 1000, function() { 
     $(this).hide(); 
    }); 
}) 

這裏是的jsfiddle http://jsfiddle.net/BrentRansom/h64CZ/4/

+0

要我看起來你需要一個「擴展」,然後根據選擇的內容設置值。感覺就像你用auto-id過分複雜。 –

+0

'.expand'類可能會訣竅 – 2013-10-03 19:28:04

+0

哦,看看誰又來了,好的,我會爲你修復代碼。我的代碼大聲笑 –

回答

0

改變ID的鏈接...

​​