programing

jquery 프리펜드+페이드인

codeshow 2023. 3. 13. 20:41
반응형

jquery 프리펜드+페이드

코드는 다음과 같습니다.

$.ajax({
        url : url,
        data : {ids : JSON.stringify(jsonids), hotel_id: hotel_id},
        success : function(response)
        {
            $('#be-images ul').prepend(response).fadeIn('slow');
        },
        dataType: 'html'
    });

페이드인은 작동하지 않습니다...나는 그 콘텐츠를 앞에 붙이고 희미하게 하고 싶다...어떻게 해야 되지?

잘 부탁드립니다!

가정하다responseHTML 이므로 다음을 시도해 보십시오.

$(response).hide().prependTo("#be-images ul").fadeIn("slow");

이렇게 하면:

$('#be-images ul').prepend(response).fadeIn('slow');

실제로 페이드 되고 있는 것은, 초기 셀렉터(앞의 리스트)의 결과이며, 이미 표시되어 있습니다.

+1에서 cletus까지입니다만, 다른 방법을 강조하고 싶습니다.

$('#be-images ul').prepend(
    $(response).hide().fadeIn('slow')
);

시험해 보세요: HTML

<button>Add</button>
<div id="data"></div>

쿼리:

$('button').click(function() {
  $('#data').prepend('<div class="item">Test</div>'"');
    $("#data .item:first-child").hide();
   $("#data .item:first-child").fadeIn();
});

라이브 데모: jsfiddle

언급URL : https://stackoverflow.com/questions/1906066/jquery-prepend-fadein

반응형