반응형
jQuery의 removeAttr로 여러 특성 제거
저는 다음과 같은 코드를 가지고 있습니다.
$(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 });
언급URL : https://stackoverflow.com/questions/13725301/remove-multiple-attributes-with-jquerys-removeattr
반응형
'programing' 카테고리의 다른 글
wp.media multiple: true 설정이 사용자 지정 플러그인에서 작동하지 않음 (0) | 2023.11.04 |
---|---|
if 조건의 쉼표 연산자 (0) | 2023.11.04 |
워드프레스 도커 컨테이너로 리디렉션할 nginx 하위 경로 (0) | 2023.11.04 |
스위프트를 가능하게 하는 것UI의 DSL? (0) | 2023.11.04 |
"ui-sref"는 링크를 두 번 클릭해도 "ui-view"(컨트롤러가 다시 실행되지 않음)를 새로 고치지 않습니다. (0) | 2023.11.04 |