Do I use , <>, >

后端 未结 15 2013
借酒劲吻你
借酒劲吻你 2020-11-22 06:10

Should I use , , or for loading SVG files into a page in a way similar to loading a jpg
15条回答
  •  青春惊慌失措
    2020-11-22 06:48

    This jQuery function captures all errors in svg images and replaces the file extension with an alternate extension

    Please open the console to see the error loading image svg

    (function($){
      $('img').on('error', function(){
        var image = $(this).attr('src');
        if ( /(\.svg)$/i.test( image )) {
          $(this).attr('src', image.replace('.svg', '.png'));
        }
      })  
    })(jQuery);
    
    
    

提交回复
热议问题