Remove multiple attributes with jQuery's removeAttr

前端 未结 2 1312
-上瘾入骨i
-上瘾入骨i 2021-02-02 05:12

I have the following code.

$(document).ready(function(){
 $(\'#listing img\')
 .attr(\'width\', 250)
 .removeAttr(\'height\').removeAttr(\'align\').removeAttr(\'         


        
2条回答
  •  深忆病人
    2021-02-02 05:23

    Yes, you can remove it in that way:

    $('#listing img').removeAttr('height align style');
    

    you can also add those attributes as follows:

    $('#listing img').attr({ height: "20", align: left }).css({ color: red, text-align: center });
    

提交回复
热议问题