jQuery의 removeAttr로 여러 속성 제거 img’) .attr(‘width’,

다음 코드가 있습니다.

$(document).ready(function(){
 $('#listing img')
 .attr('width', 250)
 .removeAttr('height').removeAttr('align').removeAttr('style')
 .wrap('<p />');
});

여러 속성을 제거하는 더 효율적인 방법이 있습니까?



답변

예 :

.removeAttr('height align style')

에서 문서 :

버전 1.7부터 공백으로 구분 된 속성 목록 일 수 있습니다.


답변

예, 다음과 같이 제거 할 수 있습니다.

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

다음과 같이 이러한 속성을 추가 할 수도 있습니다.

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


답변