How to set height , width to image using jquery

后端 未结 3 1042
情歌与酒
情歌与酒 2021-02-13 17:45

Is there any way to set height and width of an image using jquery? The following is my code

var img = new Image();  
 // Create image
$(img).load(function(){            


        
3条回答
  •  梦毁少年i
    2021-02-13 18:16

    You can call the .height() and ,.width() setters:

    var img = new Image();  
     // Create image
    $(img).load(function(){                 
        imgdiv.append(this);
    }).error(function () {  
        $('#adsloder').remove();
    }).attr({ 
        id: val.ADV_ID,  
        src: val.ADV_SRC,
        title: val.ADV_TITLE,
        alt: val.ADV_ALT
    }).height(100).width(100);
    

提交回复
热议问题