How do I check if file exists in jQuery or pure JavaScript?

前端 未结 18 2106
闹比i
闹比i 2020-11-22 00:56

How do I check if a file on my server exists in jQuery or pure JavaScript?

18条回答
  •  难免孤独
    2020-11-22 01:40

    i used this script to add alternative image

    function imgError()
    {
    alert('The image could not be loaded.');
    }
    

    HTML:

    
    

    http://wap.w3schools.com/jsref/event_onerror.asp

提交回复
热议问题