맛집 여행 캠핑 일상 생활

[jQuery] img Not Found 처리 및 function 파라메터 값 전달 방법 본문

jQuery

[jQuery] img Not Found 처리 및 function 파라메터 값 전달 방법

영은파더♥ 2019. 10. 31. 16:49

이미지 src 경로에 해당 파일이 없으면 Not found 에러가 나는데 대체 이미지를 지정할 수 있습니다.

$('img').error({param1:value1}, function(e){
    $(this).unbind('error'); // 무한루프 방지
    $(this).attr('src',e.data.param1);
  })
  .click({url:link},function(e){alert(e.data.url);});

위의 소스 코드를 보고 응용하시면 됩니다.

 

Trackback : | Comments :