$('body').on('click', function() {
$('.detailTextContainer a').each(function() {
var urlFoto = $(this).attr('href');
var imgElement = $("<img />").attr('src', urlFoto)
.addClass('dalsiFoto');
$(this).empty().append(imgElement);
});
});
페이지로드 후 (이벤트 없음) 자동으로이 기능을 어떻게 실행할 수 있습니까? '.detailTextContainer a'
은 동적 요소이며 시작 페이지 바로 다음 페이지로로드됩니다. jQuery 동적 요소 자동 실행 방법
function showImage(){
$('.detailFeatureDesc a').each(function() {
var urlFoto = $(this).attr('href');
var imgElement = $("<img />").attr('src', urlFoto)
.addClass('dalsiFoto');
$(this).empty().append(imgElement);
});
};
showImage();
을하지만이 성공적으로되지 않았습니다.
감사
참조 : http://api.jquery.com/on/ 및 https://stackoverflow.com/questions/1359018/in-jquery-how-to-attach-events-to-dynamic-html-elements –
@Kamil dynamicallly로드하는 HTML 코드 또는 앵커 태그 코드를 공유하십시오. – Shiladitya