Remove image extension using jQuery

后端 未结 3 1280
北恋
北恋 2021-01-28 01:15

Is there a way to remove from img scr extension using jQuery?

meaning from this:


         


        
3条回答
  •  攒了一身酷
    2021-01-28 01:57

    you need to provide some identification (like id, name, alt) or specific class to select image using jquery selector.

    //using css class 'special' applied to images whose
    //src we need to replace
    var i=$('img.special');
    var s = $(i).attr("src");
    s = s.substring(0, s.lastIndexOf("."));
    $(i).attr("src",s);
    

提交回复
热议问题