Is it possible to set the equivalent of a src attribute of an img tag in CSS?

后端 未结 25 2193
借酒劲吻你
借酒劲吻你 2020-11-22 09:30

Is it possible to set the src attribute value in CSS? At present, what I am doing is:


25条回答
  •  死守一世寂寞
    2020-11-22 10:21

    You can convert it with JS:

    $('.image-class').each(function(){
        var processing = $(this).attr('src');
        $(this).parent().css({'background-image':'url('+processing+')'});
        $(this).hide();
    });
    

提交回复
热议问题