javascript
  • jquery
  • 2011-10-31 4 views 1 likes 
    1

    썸네일 대체 솔루션이 있으므로 img 아이템 주위에 태그를 추가해야하며 동일한 기능을 유지해야합니다.jQuery 썸네일 대체 메소드 (태그 추가를위한 솔루션 필요)

    JQuery와

    $(".large").click(function() { 
        var thumbRel = $(this).attr("rel"); 
        $(this).effect("transfer", { to: $(".thumbnail img[rel='" + thumbRel + "']") }, 1000); 
    }); 
    
    $(".thumb").click(function() { 
        $(".thumbnail [class^='thumb']").removeClass("current"); 
        $(this).addClass("current"); 
        $(".large").attr("rel", $(this).attr("rel")); 
    
        $(this).effect("transfer", { to: $(".large") }, 1000); 
        $(".large").animate({ opacity: 1 }, 1000); 
        $(this).queue(function() { 
         $(".large").attr("src", $(this).attr("src").replace("-thumb", "")); 
    
         $(".large").animate({ opacity: 1 }, 1000); 
         $(this).dequeue(); 
        }); 
    }); 
    

    이미지 클릭에 전체 사업부를 가지고,되는 마크 업 닷 넷과 혼합되어 있지만, 여기가

    <div class="product_images">   
        <div class="mainImage">    
         <a class="ShowProductImageDlg" href="#" onclick="ProductImagesDlgClientSide.showDialog('@Model.ProductToDisplay.Product.UrlSlug', 'Bottle'); return false;" > 
          <img class="LargeImage" src="@Model.ProductToDisplay.Product.awsImageUrlLarge" alt="@Model.ProductToDisplay.Product.ProductName" /> 
         </a>    
        </div> 
        <strong>Additional Images</strong> 
        <div class="thumbnail"> 
         <ul> 
          <li><a href=""><img class="SmallImage Bottle" src="@Model.ProductToDisplay.Product.awsImageUrlSmall" 
            alt="@Model.ProductToDisplay.Product.ProductName" /></a></li>     
    
          <li><a href=""><img class="SmallImage BackLabel" src="@Model.ProductToDisplay.ProductAdditionalImageUrlSmall(awsProductImageType.BackLabel)" 
            alt="@Model.ProductToDisplay.Product.ProductName" /></a></li>    
         </ul> 
        </div>  
    </div> 
    

    최종 목표입니다 (90px x 90px) 이미지 자체가 80x35 인 경우.

    같은 jQuery를 사용하고 싶습니다.

    답변

    0

    당신은 그런 식으로이 작업을 수행 할 수 있습니다 (see jsfiddle as a proof) : 기본적으로

    var link = jQuery('<a>', { 
        'href': 'http://www.google.com/', 
        'title': 'Dynamically generated link' 
    }); 
    
    jQuery('img').wrap(link); 
    

    먼저 (링크 ( <a> 요소)를 만든 다음 img 선택에 의해 선택된 이미지 감아 당신이 할 수있는 귀하의 필요에 맞게 조정하십시오).

    +0

    그래서'display : block; 커서 : 포인터;를 이미지에 추가하고 패딩을 이미지에 추가합니다. 프레젠테이션이 아닌 이유를위한 래핑 목적의 요소를 만드는 것은 중요하지 않습니다. –

    관련 문제